[英]android listview button control
我有一个装满物品的android listview。
每个项目都有一个按钮。
这是我的列表视图的模板。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingBottom="6dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="5px"
android:paddingTop="5px"
android:paddingRight="5px"
android:gravity="left">
<TextView android:id="@+id/TextView_test1"
android:layout_width="200dip"
android:paddingLeft="0px"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/TextView_test2"
android:layout_width="250dip"
android:paddingLeft="0px"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<TextView android:id="@+id/TextView_test3"
android:layout_width="400dip"
android:paddingLeft="0px"
android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button
android:id="@+id/Button_buttontest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Button_buttontest"/>
</LinearLayout>
如何处理活动代码中的每个按钮? 每个按钮具有相同的ID“ Button_buttontest”吗?
提前致谢。 最好的祝福。 约瑟
您可能需要创建一个自定义Adapter
,以在创建行视图时将View.OnClickListener
连接到按钮。 由于您是从视图内部创建OnClickListener的,因此您将知道被单击的行的位置。 也许有更好的方法,但这是第一件事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.