Games, Community, Music etc are in Horizontal list view.
Right now Community is selected and community related data is shown below.
I want to highlight Music when it is clicked and change Community colour to default.
listview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
long arg3) {
((android.widget.LinearLayout)((android.widget.LinearLayout)arg1).getChildAt(2)).setBackgroundColor(getResources().getColor(R.color.MyBlue));
...
This changes the background colour of selected Item but when I scroll other item are also changed which are not selected. Above code changes linear layout which is define in item's xml file shown below.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/IVCategory"
android:layout_width="80dp"
android:layout_height="80dp"
android:contentDescription="@string/app_name"
android:layout_margin="10dp"
android:layout_gravity="center"
/>
<TextView
android:id="@+id/txtCatName"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center"
android:background="@android:color/transparent"
/>
<LinearLayout
android:id="@+id/selectedBlue"
android:layout_width="match_parent"
android:layout_height="3dp"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
Is that possible to do that in the way I'm doing it? I have searched a lot but I couldn't understand how selectors can help me.