[Solved] EditText does not work on FragmentActivity in Android


Try following code

Just add your all code on onCreateView() method.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_layout, container, false);

    context=getActivity();
    btnTest=(Button)context.findViewById(R.id.button1);
    edtTest=(EditText)context.findViewById(R.id.editText1);
    edtTest.setText("Test text");
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);

    builder.setTitle("Test");    
    btnTest.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            String str=edtTest.getText().toString();
            builder.setMessage(str);
            builder.show();
        }
    });
  }

    return v;
}

Hope it will work for you.

0

solved EditText does not work on FragmentActivity in Android