-1

when user click on FULL-TIME button ,I want to open fragment which should display list-view that include image, texts, and 3 dots on the right end of each view find image below. how would do this?
. enter image description here

this is my code . home.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <RelativeLayout
        android:id="@+id/layout_2nd"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/btn_full_time"
            android:layout_width="191dp"
            android:layout_height="60dp"
            android:layout_alignParentTop="true"
            android:text="@string/full_time" />

        <Button
            android:id="@+id/btn_part_time"
            android:layout_width="206dp"
            android:layout_height="60dp"
            android:layout_alignParentEnd="true"
            android:layout_alignParentRight="true"
            android:layout_toRightOf="@+id/btn_full_time"
            android:text="@string/part_time" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/layout_2nd">

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ListView
                android:id="@+id/container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

            </ListView>
        </FrameLayout>

    </RelativeLayout>


</RelativeLayout>

Do i need to create separate xml for each view or can i do that programmatically ? please suggest?

Onik
  • 15,592
  • 10
  • 57
  • 79
chand mohd
  • 1,689
  • 1
  • 7
  • 20
  • You need to populate the ListView with data programmatically, there are many ways to do that. Maybe start with something like this https://stackoverflow.com/questions/5070830/populating-a-listview-using-an-arraylist – dave May 10 '18 at 13:18
  • You need to create an xml describing single listview item. Then you need to create an Adapter class / or you can use ArrayAdapter initializing using the xml file you create. Then set that adapter to listview. – Danger May 10 '18 at 13:18
  • Yeah so check this out http://windrealm.org/tutorials/android/android-listview.php. Each ListView item/section will need a layout... The layout will have what looks like an image, textviews, and button. – dave May 10 '18 at 13:29
  • @Danger hit the nail on the head though. You need the adapter to pass your data into the individual list rows (which have a layout), then apply it to the ListView itself. – dave May 10 '18 at 13:32

1 Answers1

1

You should use android RecyclerView with custom item view holder then you can create a custom UI like your list item and add it to your RecyclerView See this example

https://www.androidhive.info/2016/01/android-working-with-recycler-view/

for three dots create LinewLayout with three Views in vertical order and give them background as custom rounded drwable as :

rounded_view.xml file in drawable folder

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <solid android:color="@color/black" />
            <size
                android:width="@dimen/dp_10"
                android:height="@dimen/dp_10" />
        </shape>
    </item>
</layer-list>

in in your main view Item xml file add this:

<LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="end"
            android:gravity="center">
                <View
                    android:layout_width="@dimen/dp_10"
                    android:layout_height="@dimen/dp_10"
                    android:background="@drawable/rounded_view"/>
                <View
                    android:layout_margin="@dimen/dp_5"
                    android:layout_width="@dimen/dp_10"
                    android:layout_height="@dimen/dp_10"
                    android:background="@drawable/rounded_view"/>
                <View
                    android:layout_width="@dimen/dp_10"
                    android:layout_height="@dimen/dp_10"
                    android:background="@drawable/rounded_view"/>
        </LinearLayout>
Mirza Ahmed Baig
  • 2,931
  • 1
  • 16
  • 33
  • seems like lengthy way of coding .I'm able to do this using ListView but unable to add **3 dotes line** and **apply** button on each view see screenshot above. – chand mohd May 10 '18 at 15:02