之前的活动没有得到

发布于 2024-12-29 14:50:26 字数 1519 浏览 2 评论 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);
            }
        });

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生再见 2025-01-05 14:50:26

查看此链接并下载其中提供的示例代码,并让我了解更多要求

单个选项卡中的多个活动

此链接中的代码也解决了您的问题

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文