Wednesday, 20 March 2013

HOW TO CHANGE ONE SCREEN TO ANOTHER SCREEN

                                                    1.CREATE NEW PROJECT

Drag and Drop Button
------------------>Right Click Button
---------------------->EditText
---------------------------->Will be Open DialogBox
--------------------------------->NewString
------------------------------------>Type Button Name on STRING option(FirstScreen)
---------------------------------------->Type Resource Id on NEW STRING R.ID (fs1)
------------------------------------------->Click ok
now Your Button Name Will be change like FirstScreen


Now right click button ,choose properties then onClick name:call2 (refer simple project link)




                                                         2.Create Second Screen

Right click Layout folder from your project
-------------------------->New
------------------------------>Android xml file
--------------------------------->Type Name on file option(second)
Do first operation darg and drop button and edittext(SecondScreen)




                                                  3.Create Another One Activity Java file

Src
------------------>Copy MainActivity.java
------------------------>Paste Sre folder
----------------------------->Change Name :sec
---------------------------------->Change setContentView like this

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
public class sec extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
    }


                                                             4.Intent Concept

Intent useful for jump One Activity to Another Activity
Src
-------------->Click MainActivity.java ,we have alredy create
                                 Method name using ONCLICK METHOD
                                       Name That is call2.
 --------------->Create function and use the INTENT SYNTEX

public class MainActivity extends Activity {
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void call2(View v)
    {
        Intent jump=new Intent(this,sec.class);
        startActivity(jump);
     }

                                                        5.ADD second Activity in AndroidManifest file

Click AndroidManifest.xml in your Project

------------------------>Application (bottom tap )
---------------------------->C option
---------------------------------->Activity
---------------------------------------->Add
----------------------------------------------->sec Activity
---------------------------------------------------->Ok

(Click this image for big view )

                                

Now Run Your Project..............!


No comments:

Post a Comment