I have a listview that uses base adapter and two layouts to display items. i have implemented multichoicemodelistener on this listview.
The issue is when i long press listview items, some are getting selected while others are not. i have realized that the ones getting selected are using a different row layout from the ones not getting selected.
layout of listview rows that are getting selected. >>>> LAYOUT 1
<?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"
android:background="?android:activatedBackgroundIndicator">
<LinearLayout
android:id="@+id/chat_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:orientation="vertical">
<com.x.y.SquareImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_gravity="center" />
<Textview
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#020202"
android:textSize="17sp"
android:textIsSelectable="false" />
</LinearLayout>
</RelativeLayout>
layout of listview rows that are not getting selected >>>> LAYOUT 2
<?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="wrap_content"
android:background="?android:activatedBackgroundIndicator">
<LinearLayout
android:id="@+id/chat_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="15dp">
<Textview
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#020202"
android:textSize="17sp"
android:textIsSelectable="true" />
</LinearLayout>
</RelativeLayout>
how i have implemented multichoice mode listener
list_View.setMultiChoiceModeListener(new Selector());
Selector class
private class Selector implements AbsListView.MultiChoiceModeListener {
@Override
public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
mode.getMenuInflater().inflate(R.menu.chat_activity_menu, menu);
return true;
}
@Override
public void onItemCheckedStateChanged(android.view.ActionMode mode, int position, long id, boolean checked) {
int checkedCount = list_View.getCheckedItemCount();
Log.d("Selector","checked items are "+checkedCount);
mode.setSubtitle(checkedCount+" selected");
}
@Override
public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
return true;
}
@Override
public void onDestroyActionMode(android.view.ActionMode mode) {
adapter.removeSelection();
}
}
Why are some of my listview items using LAYOUT 2 not getting selected? whenever i click any item using that layout, no selection occurs and even debug info isn't been printed out.