How to navigate to another screen [duplicate]
Possible Duplicate:
How to navigate from one screen to another screen
I am new to android development. can you pleas tell me, how to navigate from one Activity screen to another Activity screen .In the first screen i m having one ListView of 4 components, if i click on one of them it has to move to another Activity screen. What methods the new screen should implement so as to go to some next screen.
I am adding my code for reference. GetParameter.class is the new activity to be called. This is not working. what might be the reason? public void onListItemClick(ListView parent, View v, int position, long id)
{
if (position == 0) {
startActivity(new Intent(this, GetParameter.class));
GlobalFunctions.startCommonDate(1, 2, 1);
startActivity(new Intent(this, newone.class));
} else if (position == 1) {
GlobalFunctions.startCommonDate(2, 2, 1);
startActivity(new Intent(this, newone.class));
开发者_JS百科 } else if (position == 2) {
GlobalFunctions.startCommonDate(3, 2, 1);
startActivity(new Intent(this, newone.class));
} else if (position == 3) {
start_Customdate();
}
}`
Try this
startActivity(new Intent(From.this,To.class));
Also in manifest file sign All the activities you used
Android use Intent objects for sending messages between Activities and opening/starting new Activities.
I suggest you to read this: http://www.vogella.de/articles/AndroidIntent/article.html and/or go through these 3 exercises: http://developer.android.com/resources/tutorials/notepad/index.html
Intent intent=new Intent(source.this,destination.class);
startActivity(intent);
You start a new intent inside your click listener
ListView lv = getListView();
lv.setOnItemClickListener(adapterAndListener);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Intent myIntent = new Intent(CurrentActivity.this, NextActivity.class);
CurrentActivity.this.startActivity(myIntent);
}
});
You can find more information about ListView in the following example:
http://developer.android.com/resources/tutorials/views/hello-listview.html
I agree with Rasel's response.
On top of this you can consider using startActivityForResult()
/ onActivityResult()
should your daughter Activity
need to send back something to its parent.
More details here:
startActivityForResult()
onActivityResult()
Inside ur listview onclick use this code,
Intent myIntent = new Intent(FirstActivity.this, secondActivity.class);
精彩评论