简体   繁体   English

引导用户点击ListView中的项目进行新活动

[英]Leading user to new activity clicking on item in ListView

在此输入图像描述 ListView is created from Cursor with data from DB. ListView是从Cursor创建的,其中包含来自DB的数据。

Clicking on each item in ListView leads user to a new Activity/Page/Layout/WHAT? 单击ListView中的每个项目会将用户引导到新的活动/页面/布局/内容? where additional info + pictures about the item are shown. 其中显示有关该项目的其他信息+图片。

Do I need to create dynamic activities? 我需要创建动态活动吗? Or there is a better way that I just do not know about? 或者有一种我不知道的更好的方法?

Thank you in advance. 先感谢您。

If each item has a sufficiently common format for displaying your "additional info + pictures", then I would suggest creating a single Activity to represent your items, and then fill in the details by passing the item as an extra on the Intent that launches your activity. 如果每个项目都有足够常用的格式来显示“其他信息+图片”,那么我建议您创建一个活动来表示您的项目,然后通过将该项目作为额外内容传递给启动您的Intent来填写详细信息活动。 For example, 例如,

In the list activity: 在列表活动中:

Intent intent = new Intent(ITEM_DETAILS_INTENT);
intent.putExtra(ITEM_NAME, itemName);
startActivity(intent);

and in the item detail activity: 并在项目详细活动中:

Intent intent = getIntent();
String itemName = intent.getStringExtra(ITEM_NAME);
populateDetails(itemName);

On the other hand, if "Controls" requires a significantly different format from "Focus", you'll need a ControlsActivity and FocusActivity (for example) where each activity handles each item, and you launch a different activity depending on the item selected. 另一方面,如果“控件”需要与“焦点”显着不同的格式,则需要一个ControlsActivity和FocusActivity(例如),其中每个活动处理每个项目,并根据所选项目启动不同的活动。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM