之前的活动没有得到
我正在开发包含 4 个选项卡的选项卡主机应用程序。每个选项卡都有列出项目的单独活动。单击每个选项卡的项目会转到另一个活动,在同一选项卡主机屏幕布局中显示单击的列表项目的详细信息。
如果我在单击选项卡主机中的项目后按后退按钮,应用程序将退出。但我需要访问之前到达的列表和选项卡。如何实现这一目标?预先感谢
这是我的示例代码 -
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.list,
new String[] { "title","shortdescription"},
new int[] { R.id.titleTextView,R.id.descriptionTextView});
ListView list = (ListView)findViewById(R.id.statutesListView);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
HashMap<String, String> hashMap = new HashMap<String, String>();
hashMap = (HashMap<String, String>) parent.getItemAtPosition(position);
String newstitle = hashMap.get("title");
String newsdesc = hashMap.get("shortdescription");
//Get the new Activity to tab.
Intent intent = new Intent(getApplicationContext(), detailedview.class);
Bundle bundle = new Bundle();
bundle.putString("title", newstitle);
bundle.putString("desc", newsdesc);
intent.putExtras(bundle);
View setview = getLocalActivityManager().startActivity("statutes", intent).getDecorView();
setContentView(setview);
}
});
I am working on tab host application containing 4 tabs. Each tab has individual activity that lists items. on item click of each tab takes to another activity displaying details of clicked list item in same tab host screen layout.
If i press back button after clicking an item from tab host, the application exits. But i need to visit the previously reached list and tabs. How to achieve this? Thanks in Advance
This is my Sample Code -
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.list,
new String[] { "title","shortdescription"},
new int[] { R.id.titleTextView,R.id.descriptionTextView});
ListView list = (ListView)findViewById(R.id.statutesListView);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
HashMap<String, String> hashMap = new HashMap<String, String>();
hashMap = (HashMap<String, String>) parent.getItemAtPosition(position);
String newstitle = hashMap.get("title");
String newsdesc = hashMap.get("shortdescription");
//Get the new Activity to tab.
Intent intent = new Intent(getApplicationContext(), detailedview.class);
Bundle bundle = new Bundle();
bundle.putString("title", newstitle);
bundle.putString("desc", newsdesc);
intent.putExtras(bundle);
View setview = getLocalActivityManager().startActivity("statutes", intent).getDecorView();
setContentView(setview);
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看此链接并下载其中提供的示例代码,并让我了解更多要求
单个选项卡中的多个活动
此链接中的代码也解决了您的问题
Check this link out and download sample code provided in it and let me know for more requirements
multiple activities in single tab
This code in this link also solves your problem