I have a layout with a listView
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/testMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="@+id/notesListView"
android:layout_width="480dp"
android:layout_height="wrap_content"
android:background="#000"
android:divider="#FFF"
android:dividerHeight="5dp"
android:fadingEdge="none"
android:overScrollFooter="#000"
android:layout_marginBottom="15dp"
/>
</RelativeLayout>
I use ListView_Adapter to add items to the list dynamically. Is it possible to add a button to the right corner of every row of the list?
Yes you have to go for custom listview.In custom ListView you have to add listitem dynamically from layout xml file.
Example :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/testMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<Button
android:id="@+id/notesListView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
make your listitem xml to
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="8dp">
<TextView
android:id="@+id/title"
android:textColor="#FFF"
android:layout_width="120dp"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/Btn01"
android:textColor="#000"
android:layout_weight="0.20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button1"/>
</LinearLayout>
Check this Buttons on List View
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.