单击前一个 ListView 上的某一行后,如何打开另一个 ListView?
我想知道如何在单击前一个 ListView
上的某一行后打开另一个 ListView
?
Bee VOA reader 可能是一个很好的例子来了解我在说什么。
List A List B
DeskTop Development ---> Buttons
TextView
ScrollBar
Mobile
Graphic
Game
所以手机屏幕上有一个列表A,列表A中有很多主题 如果我点击其中一个主题,比如说桌面开发,那么整个 ListView 将从屏幕上滑出,并显示新的列表 B。
那么如何实施呢?
I want to know how to open another ListView
after one of rows on the previous ListView
has been clicked?
Bee VOA reader could be a good example to see what I'm talking about.
List A List B
DeskTop Development ---> Buttons
TextView
ScrollBar
Mobile
Graphic
Game
So there is one list A on the phone's screen, and there are many topics in the list A
If I clicked on one of the topic,let's say DeskTop Development, then the whole ListView
will be slided away from the screen and the new List B will be presented.
So how to implement it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
打开一个新的活动,同时传递适当的数据以显示正确的信息,是完成您正在做的事情的好方法。这是一个州列表的代码示例,该列表转到上一个列表中所选州的城市列表。第一个活动中的州列表视图将州名称发送到第二个活动中的城市列表视图,第二个活动显示该州的城市列表。
///////////////////////后退按钮代码允许您返回到上一个列表(关闭需要在 onDestroy() 中关闭的任何内容):
// /////////////////////动态添加项目到列表中:
//////////////////////Extra信用:每个 listView 项目的布局 - R.layout.list_item(res/layout 文件夹中的 list_item.xml):
Opening a new Activity while passing the appropriate data to display the correct information is a good way to do what you're doing. This is a code example of a list of states which goes to a list of cities in the selected state from the previous list. The state listview from the first activity sends the name of the state to the city listview in second activity which displays a list of cities from that state.
//////////////////////back button code allowing you to go back to the previous list (close anything that need to be closed in onDestroy()):
//////////////////////adding items to your list dynamically:
//////////////////////Extra Credit: Layout for each listView item - R.layout.list_item (list_item.xml in the res/layout folder):
实现 onListItemClick() 方法,以便单击时启动一个新的 ListActivity。这样,菜单中的导航将更加容易,因为您将能够使用后退按钮。
Implement the onListItemClick() method so that on click it starts a new ListActivity. This way the navigation in the menu will be easier as you will be able to use the back button.