Monday 15 June 2015

android intent - how to link 3 different buttons with 3 different activities? -


On my menu screen I have 3 buttons and I want to add them to 3 different activities. Various activities will expand in every single button. How is this possible? I have no problem with 1 class and activity, but when there is a problem, I have a problem. Thank you.

assuming that you have main activity , SettingsActivity < There are three activities named / code> and ProfileActivity , you can:

  @ Override public boolean on option items select (item item) {intent intent; Class & lt ;? & Gt; CLS; Switch (item.getItemId ()) {case R.id.main: cls = MainActivity.class; break; Case R.id.settings: cls = ScheduleView.class; break; Case RID Profile: CLS = UserprotectionActivate.class; break; Default: Log D. (This.getClass (). GetSimpleName (), "should not be"); return false; } Intent = new intent (getApplicationContext (), CLS); StartActivity; Back true; }    

No comments:

Post a Comment