android - Click list item will move into another activity class -


public class mainactivity extends activity {

private menu addmenubutton;   @override     protected void oncreate(bundle savedinstancestate)         {     super.oncreate(savedinstancestate);     setcontentview(r.layout.mainact);     public void onpopup(view view) {     popupmenu menu=new popupmenu(this,view);     menu.getmenuinflater().inflate(r.menu.menu1,menu.getmenu());     menu.setonmenuitemclicklistener(new popupmenu.onmenuitemclicklistener()     {         public boolean onmenuitemclick(menuitem item)         {             toast toast=toast.maketext(mainactivity.this,                     item.gettitle()+"selected",toast.length_short);             //intent intent2 = new intent(mainactivity.this, yourspotactivity.class);             //startactivity(intent2);       toast.show();     return true;         }     });     menu.show();  } } 

please tell solution move activity when click on item list. new program. first program. try explain in depth. in advance.

intents used move 1 activity another.

an intent message did or want happen. depending on intent, apps or os might listening , react accordingly.

explicit intent

intent intent2 = new intent(mainactivity.this, yourspotactivity.class); startactivity(intent2); 

remember add activity in androidmanifest

 <activity android:name="com.example.abc.youractivity" > </activity> 

this call yourspotactivity i.e activity visible , mainactivity remain on stack , when press button mainactivity visible again

  • in explicit intent, specify activity required respond intent. in other words, explicitly designate target component.

  • in implicit intent , declare intent , leave android platform find activity can respond intent.

related links:

what intent in android?

what format android intent?

intent tutorial

p.s- why have commented intent code ?? uncomment , code work


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -