In Android, how to switch the page [duplicate]
Possible Duplica开发者_运维技巧te:
Moving from One activity to next in Android
i have two classes, how do I switch from one page to another page?
Both classes have to extend Activity, and be defined in the AndroidManifest.xml
To start Class2 from Class1 do this:
Intent i = new Intent(Class1.this, Class2.class);
startActivity(i);
AndroidManifest.xml:
<activity android:name="Class1"
android:label="Class1">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="Class2" android:label="Class2"></activity>
You can do this with the help of Intents. Just use the following code in one of the page
Intent i=new Intent("completepagename");
startActivity(i);
where the page name A is like packagename.A
One page into other page in the sense..Is it another activity?
In case of another activity u need to call that activity using intent
only..
Intent intent = new Intent();
intent.setClass(firstclass.this,SecondClass.class);
startActivity(intent);
Also go through this link.. start a new activity
Hope it will help you
you have to defined the activity in manifest file and both class have extend the class
Intent i = new Intent();
i.setAction(android.intent.action.NEW_ACTIVITY);
startActivity(i);
In Android Manifest.xml
<activity android:name="Baseclass"
android:label="BaseClass">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="NewActivity" android:label="NewActivty">
<intent-filter>
<action android:name="android.intent.action.NEW_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
精彩评论