-3

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.

KENdi
  • 7,576
  • 2
  • 16
  • 31
Atif Rizwan
  • 645
  • 2
  • 8
  • 17

1 Answers1

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