I want to create a custom listview in which 2 buttons and two textviews. Like this(Image of List view). When user click on these buttons then status is changed to particular user. Click on Approve then Status is changed as Approved Click on Disapprove Status is changed as Disapproved My database structure is like this I check all examples here but these are not enough to create this type of list.
Asked
Active
Viewed 462 times
-3
-
i recommend use Recyclerview instead of listview – Pritesh - ɐʎıɥpɐΛ ɥsǝʇᴉɹꓒ Jul 20 '17 at 04:31
-
You need to create custom adapter for that https://stackoverflow.com/questions/8166497/custom-adapter-for-list-view – ManishNegi Jul 20 '17 at 04:33
-
Did you try anything? – debugger Jul 20 '17 at 04:42
-
follow this link : http://www.journaldev.com/10416/android-listview-with-custom-adapter-example-tutorial – batsheva Jul 20 '17 at 04:49
1 Answers
0
Here have a look at my other answer just change the parameters according to you https://stackoverflow.com/a/44492259/7290822
and use this layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:background="@drawable/row_selector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:gravity="center"
android:layout_marginTop="8dp"
android:id="@+id/rowLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image"
android:gravity="center"
android:textSize="22sp"
android:text="Name: Tahir"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/name"
android:text="Approve"
android:padding="4dp"
android:background="#e2e2"
android:gravity="center"
android:textSize="22sp" />
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/price"
android:text="Disapprove"
android:padding="4dp"
android:layout_marginTop="8dp"
android:background="#ed1c24"
android:gravity="center"
android:textSize="22sp" />
</LinearLayout>
</LinearLayout>
Let me know if you stuck somewhere. Hope it helps!!!

sumit
- 1,047
- 1
- 10
- 15
-
Thanks alot bro..Can you tell me if i have two textboxes first is for name and second for user id. how to set user name and id on these textboxes. User id and name is retrieved from firebase database – Atif Rizwan Jul 20 '17 at 08:57
-
see this line I am sending my list of type data to the listview adapter class mAdapter = new ListViewAdaptor(mDataList); you have to store your data in mDataList and then in adapter class @Override public void onBindViewHolder(MyViewHolder holder, int position) { Data data = mDataList.get(position); holder.name.setText(data.getName()); holder.price.setText(data.getPrice()); holder.imageView.setImageResource(data.getImageId()); } retrieve the data and set it – sumit Jul 20 '17 at 09:20
-
if you need only two fields you can remove the third field from data class and make necessary changes – sumit Jul 20 '17 at 09:21