android - How to start new activity on button click -


in android application, how start new activity (gui) when button in activity clicked, , how pass data between these 2 activities?

easy.

intent myintent = new intent(currentactivity.this, nextactivity.class); myintent.putextra("key", value); //optional parameters currentactivity.this.startactivity(myintent); 

extras retrieved on other side via:

@override protected void oncreate(bundle savedinstancestate) {     intent intent = getintent();     string value = intent.getstringextra("key"); //if it's string stored. } 

don't forget add new activity in androidmanifest.xml:

<activity android:label="@string/app_name" android:name="nextactivity"/> 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -