Blog Archives

Android Create Intent In Fragment

When working with Fragment if you have any links which forward the user to another Activity you have to change the source parameter to “fa”. For further information on fa take a look at this. This will look like this:

Posted in Android, Tips and Tricks Tagged with: , ,

Android Create Toast In Fragment

To create a Toast in Fragment first take a look at the steps here When that is in order, extended Fragment and create the fa object you can create your Toast like this: Toast.makeText(fa, message, Toast.LENGTH_LONG).show(); Previous step. Next step.

Posted in Android, Tips and Tricks Tagged with: , ,

Android Access Element In Fragment

When you convert an Activity to Fragment there is another way for you to access your element e.g. a Textview. Before TextView myTextView = (TextView) findViewById(R.id.myTextView); to TextView myTextView = (TextView) ll.findViewById(R.id.myTextView); Previous step. Next step.

Posted in Android, Tips and Tricks Tagged with: , ,

Android Convert Intent to Fragment

To use Intent in a Fragment class you can convert it this way. For the fa object see the previous step. Before intent = getIntent(); to fa = super.getActivity(); intent = fa.getIntent(); Previous step. Next step.

Posted in Android, Tips and Tricks Tagged with: , ,

Android Convert onCreate() to Fragment

onCreate() is mandatory for both an Activity and Fragment. They differ a bit. To see how to change your Activity to a Fragment take a look at the previous step. Before: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.outer_layout); } After: private

Posted in Android, Tips and Tricks Tagged with: , ,

Android Convert Activity to Fragment

To convert your activity to a fragment there are a few changed you’ll have to do. First of all you change extends Activity to extends Fragment in those classes. Before: public class Main extends Activity { } After: public class Main extends Fragment {

Posted in Android, Tips and Tricks Tagged with: , ,

Android Fragment Save States Of Views

To save the Fragment state in Android you can do this. First save the state: @Override     public void onSaveInstanceState(Bundle outState) {         super.onSaveInstanceState(outState);         outState.putInt(“curChoice”, mCurCheckPosition);     } And later use

Posted in Android, Tips and Tricks Tagged with: , ,