2012-01-28 70 views
0

我正在使用包含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); 
      } 
     }); 
+0

你不能这样做:View setview = getLocalActivityManager()。startActivity(“statutes”,intent).getDecorView(); setContentView(setview); – 2012-01-28 09:59:00

+0

是的,它的工作,但它会完成我的应用程序,当我按回来按钮 – Praveenkumar 2012-01-28 10:27:13

回答

1

检查此链接并下载示例代码,它提供的,让我知道了更多的要求

multiple activities in single tab

此代码这个链接也解决了你的问题

+0

是的,这很有用 – Praveenkumar 2012-01-28 13:11:08

+0

我有一个使用这种方法的错误。 – Praveenkumar 2012-01-28 14:04:08

+0

我的朋友让我知道什么样的错误 – 2012-01-30 06:47:59

相关问题