项目删除ID列表视图中点击 [英] Remove ID of item clicked in list view
本文介绍了项目删除ID列表视图中点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
| Icon(image) | Title(text) | cross(image) |
| | Description(text)| |
| | | coupon(image) |
它的列表视图。
这里的时候,像十字架,优惠券列表视图中单击分开我想获得不同项的ID,图标点击,然后我会得到他们的ID ...
我是个新手...请帮我....
Its a list view. Here i want to get id of different items when clicked separately in list view like cross, coupon, icon is clicked then i will get their id... I'm a newbie...Please help me out....
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/list_item_iv_icon"
android:layout_width="100dp"
android:layout_height="100dp"
android:contentDescription="@string/app_name"
android:paddingLeft="10dp"
android:paddingRight="10dp" />
<ImageView
android:id="@+id/list_item_iv_icon_cross"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:clickable="true"
android:contentDescription="@string/app_name"
android:src="@drawable/cross_selector" />
<TextView
android:id="@+id/list_item_tv_title"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_toRightOf="@+id/list_item_iv_icon"
android:gravity="left"
android:textColor="#CC0033"
android:textIsSelectable="false"
android:textSize="20sp" />
<TextView
android:id="@+id/list_item_tv_desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/list_item_tv_title"
android:layout_toRightOf="@+id/list_item_iv_icon"
android:gravity="left"
android:textColor="#3399FF"
android:textIsSelectable="false"
android:textSize="14sp" />
<ImageView
android:id="@+id/list_item_iv_type"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignBottom="@id/list_item_iv_icon"
android:layout_alignParentRight="true"
android:contentDescription="@string/app_name" />
</RelativeLayout>
我知道如何获得点击列表中的ID。我想知道的是如何让在列表中单击项目的项目标识。
I know how to get id of the clicked list. i want to know is how to get item id of a clicked item in list.
推荐答案
下面是答案像我这样的新手...
Here is the answer for NewBies like Me...
<ImageView
android:id="@+id/list_item_iv_icon_cross"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:clickable="true"
android:contentDescription="@string/app_name"
android:src="@drawable/cross_selector"
android:onClick="onCrossClick" />
我用的onClick有关项目,并获得在它已被点击我使用的位置
i used onClick on item and to get position in which it has been clicked i used
final int position = listView.getPositionForView((View) v.getParent());
满code: -
full code :-
public void onCrossClick(View v) {
final int position = listView.getPositionForView((View) v.getParent());
Toast.makeText(this, "click on button " + position, Toast.LENGTH_LONG)
.show();
}
这篇关于项目删除ID列表视图中点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文