如何导航到另一个屏幕
可能重复:
How to navigate from one screen to another screen如何导航到另一个屏幕
我是新android开发。你能否请求告诉我,如何从一个活动屏幕导航到另一个活动屏幕。在第一个屏幕中,我有一个4个组件的ListView,如果我点击其中一个,它必须移动到另一个活动屏幕。 新屏幕应执行哪些方法以进入下一个屏幕。
我正在添加我的代码以供参考。 GetParameter.class是要调用的新活动。这不起作用。可能是什么原因?
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));
} else if (position == 2) {
GlobalFunctions.startCommonDate(3, 2, 1);
startActivity(new Intent(this, newone.class));
} else if (position == 3) {
start_Customdate();
}
}`
试试这个
startActivity(new Intent(From.this,To.class));
而且清单文件您登录使用
的一切活动,你开始你的点击监听器里一个新的意图
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);
}
});
你可以找到更多有关ListView的信息,请参阅以下示例:
http://developer.android.com/resources/tutorials/views/hello-listview.html
内部乌尔列表视图的onclick使用此代码,
Intent myIntent = new Intent(FirstActivity.this, secondActivity.class);
他使用的是一个不是按钮的列表视图 – Rob
的Android使用意图对象发送活动和打开/开始的新活动之间的消息。
我建议你阅读本: http://www.vogella.de/articles/AndroidIntent/article.html 和/或经过这些练习3: http://developer.android.com/resources/tutorials/notepad/index.html
我同意RASEL的响应。 在此之上,你可以考虑使用startActivityForResult()
/onActivityResult()
如果你的女儿Activity
需要发回东西给它的父母。
更多细节在这里:
我sugggest你读这http://andbook.anddev.org/。这真的是一个很好的介绍给android。你的应用程序中缺失的部分是Intents。 – Snicolas
谢谢Snicolas! – Soniya
此问题有多个重复项。请阅读[问]了解hpw [SO]的作品。搜索功能非常好,可以节省您的时间。请参阅[这个问题的重复](http://stackoverflow.com/search?q=How+to+navigate+to+another+screen) – Merlin