Updated Android Studio to 0.2.6 you can run into this error: “Error: Default activity not found”, almost every line was red and some other irrelevant error. Nothing was changed in the project, only did the update from 0.2.5 to 0.2.6. Do the following to fix the problem: Build -> Rebuild Project and then restart Android
Tag: activity
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: Intent explicitIntent = new Intent(fa, AuthorInformation.class); startActivity(explicitIntent); Previous step.
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.
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.
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.
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 LinearLayout ll; private FragmentActivity fa; public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { fa
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 { } Next step