Popular Posts

There was an error in this gadget

Dec 28, 2011

End of the year with new Things (its Android !!! )

-Create a new android project. named it to Android_project
-open main.xml file
-take a button from the palette.you can change its properties by openning the properties window.
-save it.now you can see its id in R.java file.
-now open the Android_projectActivity.java file and type the code bellow..

                Button b = (Button) findViewById(R.id.button1);
        b.setOnClickListener(new OnClickListener() {                   //(ctrl+1 choose import)
                                                public void onClick(View v) {
                                                                // TODO Auto-generated method stub
                                                                startActivity(new Intent(Android_projectActivity.this, Second.class));

You can take some advantages by pressing ctrl+space, ctrl+1.

-Now create another class.select src folder. right click-> new -> class.
-Give the name of the class.I named it Second.In the Superclass click on the Browse... Type Activity -> Choose Activity - android.app

-Create xml file for the second activity
- Right click on Layout -> New ->Other->Android XML File

-Take a text attribute and change the text from properties…

-In the Manifest file add the line
<activity android:name=".Second"></activity>

-          In the Second.java class add the lines
protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub

setContentView(R.layout.second) This line of code show the contents of the xml file.