Created
November 28, 2014 02:38
-
-
Save CreatorB/b585113c2a154e29fe43 to your computer and use it in GitHub Desktop.
ButtonIntentAndroid - creatorb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//activity I | |
import android.app.Activity; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.os.Bundle; | |
import android.widget.Button; | |
import android.view.View; | |
import android.view.View.OnClickListener; | |
public class AppActivity extends Activity { | |
Button button; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
addListenerOnButton(); | |
} | |
public void addListenerOnButton() { | |
final Context context = this; | |
button = (Button) findViewById(R.id.button1); | |
button.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View arg0) { | |
Intent intent = new Intent(context, App2Activity.class); | |
startActivity(intent); | |
} | |
}); | |
} | |
} | |
//activity II | |
import android.app.Activity; | |
import android.os.Bundle; | |
import android.widget.Button; | |
public class App2Activity extends Activity { | |
Button button; | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment