[英]Getting a particular detail from XML file in android
I am working on a CRM app in android, in which, I am showing details of all contacts in a list view. 我正在使用android中的CRM应用程序,其中,我在列表视图中显示所有联系人的详细信息。 Now, my requirement is when I click on a particular item in the list, it should only display the details about selected contact, such as, name, address, email, etc.. The data is coming from XML file, which I am parsing using SAX Parser.
现在,我的要求是,当我单击列表中的特定项目时,它应该仅显示有关所选联系人的详细信息,例如姓名,地址,电子邮件等。数据来自我正在解析的XML文件。使用SAX Parser。 How can I query a XML to get selected data?
如何查询XML以获取所选数据?
You are filling the ListView
using Adapter
right? 您正在使用
Adapter
填充ListView
吗? Now you can get the item at the selected view inside the ListView
and pass this item to an Activity
. 现在,您可以在
ListView
内的选定视图中获取该项目,并将该项目传递给Activity
。
Eg inside your Adatper
class implement the onItemClickListener
: 例如,在您的
Adatper
类内部,实现onItemClickListener
:
public void onItemClick(AdapterView<?> a, View v, int position, long l) {
// Remembers the selected Index
Data item =getItem(position);
Intent intent = new Intent(getApplicationContext(), DetailedActivity.class);
intent.put("object",item);
startActivity(intent);
}
Note: the item "Data" class should implement the Parsable
interface so it can be passed to the Activity
in your DetailedActivity
onCreate
method get that object and update the UI
based on its Values. 注:项“数据”类应实现
Parsable
接口,因此它可以被传递到Activity
中您DetailedActivity
onCreate
方法来获取该对象和更新UI
基于其价值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.