[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(); … Read more

[Solved] How convert my existing activities to fragment with the same functionality and layout?

You need to create a new fragment, and add the functionality from the activity’s life cycle to the fragment’s life cycle. For example: your activity’s onCreate()’s code should be implemented in onCreateView() of the fragment, off course you’ll have to change some stuff like inflatting the view and returning it instead of calling setContentView(R.layout.id). Implement … Read more

[Solved] getActivity() From Fragment to Fragment returning null

adapter.setOnItemClickListner(new DailyMenuFrag()); The new DailyMenuFrag() here is a new fragment and it is not attached to any activity and hence getActivity() returns null. Looks like you should use adapter.setOnItemClickListner(this); instead to use the current DailyMenuFrag instance as item click listener. solved getActivity() From Fragment to Fragment returning null