I have this custom layout, row.xml in my ListView
rows:
<?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="40dp"
android:orientation="horizontal"
android:weightSum="10">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9"
android:id="@+id/rowTextView"
android:typeface="serif"
android:gravity="center_vertical"
android:textSize="15sp"
android:layout_marginLeft="5dp" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/swipeImageView"
android:src="@mipmap/swipe"
android:alpha="0.5"
android:padding="11dp" />
</LinearLayout>
Now I want to change row.xml for this layout clicked_row.xml when using onListItemClick()
:
<?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="40dp"
android:orientation="horizontal"
android:weightSum="10">
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9"
android:id="@+id/rowTextView"
android:typeface="serif"
android:gravity="center_vertical"
android:textSize="15sp"
android:layout_marginLeft="5dp" />
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="@+id/saveImageView"
android:src="@mipmap/trash"
android:alpha="0.5"
android:padding="11dp" />
</LinearLayout>
I was trying to use this answer; but they seem to be manipulating the visibility of views inside the layouts rather than replacing one layout for the other. I'm not sure what I should use to replace the row.xml for clicked_row.xml:
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
//Code for replacing row.xml with clicked_row.xml
}
Thanks on any help!