如何将selectedListItem的对象传递到另一个活动? [英] How to pass the selectedListItem's object to another activity?

查看:68
本文介绍了如何将selectedListItem的对象传递到另一个活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计的活动,其中有一个ListView。我想这对点击列表项的一个新的活动应该开始,它应包含相关的列表项clicked.Please详细数据帮我在做this.Thanks提前。

I have designed an activity in which there is a listView. I want that on click of the list item a new Activity should start and it should contain detail data related to the ListItem clicked.Please help me out in doing this.Thanks in advance.

推荐答案

当启动一个活动中使用 putExtra 将数据发送到另一个活动

While starting an activity use putExtra to send data to another activity

Intent i = new Intent(this, SecondActivity.class);
i.putExtra("listitemselected", listitemvalue);
startActivity(i);

SecondActivity.java 使用 getStringExtra 来获取值。

Intent i = getIntent();
String listItem = i.getStringExtra("listitemselected");

这篇关于如何将selectedListItem的对象传递到另一个活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆