[英]i have some problems in java Class i cant get EditText as string
package com.example.dato.task;
包 com.example.dato.task;
import android.app.DialogFragment;
导入 android.app.DialogFragment; import android.os.Bundle;
导入 android.os.Bundle; import android.support.annotation.Nullable;
导入 android.support.annotation.Nullable; import android.view.LayoutInflater;
导入 android.view.LayoutInflater; import android.view.View;
导入 android.view.View; import android.view.ViewGroup;
导入 android.view.ViewGroup; import android.view.Window;
导入 android.view.Window; import android.widget.Button;
导入 android.widget.Button; import android.widget.EditText;
导入 android.widget.EditText; /** * Created by DATO on 2/17/2018.
/** * 由 DATO 于 2/17/2018 创建。 */
*/
public class DialogClass extends DialogFragment{
公共类 DialogClass 扩展了 DialogFragment{
public DialogClass(){} String s; String s1; @Nullable @Override public View onCreateView( LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { final View dialogView= View.inflate(getActivity(), R.layout.dialog, null); getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); final EditText e1 = dialogView.findViewById(R.id.text1); final EditText e2= dialogView.findViewById(R.id.text2); Button bt = dialogView.findViewById(R.id.button); bt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view){ s = e1.getText().toString(); s1 = e2.getText().toString(); dismiss(); } }); return dialogView; }
}
It's probably that in your dialog.xml
layout you haven't the editTexts with the IDs "text1" and "text2".可能是在您的
dialog.xml
布局中,您没有 ID 为“text1”和“text2”的 editTexts。
The IDs can be different. ID 可以不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.