添加按钮,列表视图中的每一行 [英] Adding button to each row in listview
问题描述
我要添加按钮,列表视图我的每一行。我在布局文件夹中创建 row.xml
称为XML文件,并增加了两个textviews并在该文件中的一个按钮。但是,当添加一个按钮,我无法点击列表视图的项目。我只能够单击按钮。这里是 row.xml
:
I want to add button to each row of my listview. I created an XML file called row.xml
in my layout folder and added two textviews and a button in that file. But when a button is added, I am unable to click the item of listview. I'm only able to click the button. Here is row.xml
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text11"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="#000000"
/>
<TextView
android:id="@+id/text2"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:textColor="#000000"
/>
<Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>
我要引用textviews和按钮在我的活动。请帮助我,并提出一些想法。
I want to refer to textviews and button in my activity. Please help me and suggest some ideas.
推荐答案
看的Android - 动态添加到浏览视图,动态添加和删除Android的意见?和的Android,添加新的视图,而XML布局 ,的Android,第三部分:动态布局
希望这会帮助你。
谢谢,
编辑:为了在列表视图按钮单击事件只是检查处理按钮点击在ListView行,<一个href=\"http://stackoverflow.com/questions/5013749/click-event-for-the-button-inside-listview-in-android\">click事件在android系统里面列表视图按钮,
For button click event in listview just check Handling Button clicks in a ListView Row,click event for the button inside listview in android,
这篇关于添加按钮,列表视图中的每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!