I have created an expandable listView
where I am showing text side by side more likely I wanna show a table of 2 columns there. For that, I have used the expandable list view and so far it looks like this(The image below).
But I want to change the color of the first line of this list. something like this(image below).
As for code, I have used two text views in a horizontal Linear Layout
and with a custom adapter I am showing the data in the view. here's the XML.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/itemText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textSize="16sp"
android:text="item"/>
<TextView
android:id="@+id/itemText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textSize="16sp"
android:text="Item2"/>
</LinearLayout>
Can anyone suggest what should I do to achieve this?
In your adapter if position = 0
itemText.setBackgroundColor(int colour);
Also you should use RecyclerView instead of ListView