ListView数据解析和导航
我有物品清单。该项目在数据库中具有与其相关的详细信息。我想单击列表中的一个项目,然后导航到一个活动,该活动在 EditText 中显示该项目的详细信息。我已经有了导航部分,但我无法执行最重要的部分,即显示我单击的项目的详细信息。
这是我的导航方法
edition.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final String aux= (String) lt.getItemAtPosition(position);
Intent myIntent = new Intent(infoList.this, EditarLocais.class);
startActivity(myIntent);
}
});
有人可以帮忙吗?
谢谢
I have list of items. This items have details associated with them, in the database. I want to click on a item of the list and that navigate to a activity that shows the details of this items in a EditText. I already have the navigation part but i can't do the most important part that consist in show the details of the item i clicked.
this is my method for navigation
edition.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
final String aux= (String) lt.getItemAtPosition(position);
Intent myIntent = new Intent(infoList.this, EditarLocais.class);
startActivity(myIntent);
}
});
Can somebody help?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以“Android Way”执行此操作,
然后在 ItemActivity 中使用 ContentProvider
:
do it in "Android Way"
use ContentProvider
then in ItemActivity:
选项#1:
Application
类可能就是您正在寻找的。有一个很好的答案解释了如何使用它,实际上它就是您需要的一切。您可以在这里找到答案: Android:如何声明全局变量?。选项 #2:
使用
Intent.putExtra(...)
方法将更多数据从上一个Activity
发送到下一个Activity
。选项#3:
这是一个肮脏的快速修复(不推荐)。将您的数据对象声明为
static
,并使用YourActivity.mMyDataObject
访问它。Option #1:
The
Application
class could be what you're looking for. There is a very good answer that explains how to use it and actually it is everything you need. You can find the answer here: Android: How to declare global variables?.Option #2:
Use
Intent.putExtra(...)
method to send further data from your previousActivity
to your nextActivity
.Option #3:
This is a dirty quick fix (not recommended). Declare your data object as
static
and reach it by usingYourActivity.mMyDataObject
.