Thursday, March 31, 2011

Create a button for your Android App

Step 1- Drag a button from your interface into the .xml document

Step 2- Give the button an id name inside xml file

Step 3- Go into java file and type the following code:

Button myButton = (Button) findViewById(R.id.button1);
myButton.setOnClickListener(new View.onClickListener) {

Eclipse will finish your button method below --

}
Step 4- Use startActivity and create new Intent.

Step 5 - Add your intent into the Android manifest

No comments:

Post a Comment