Java 使用3个选项卡(viewpager2)删除应用程序中的多个元素,每个选项卡带有一个片段,每个片段带有recyclerviews

Java 使用3个选项卡(viewpager2)删除应用程序中的多个元素,每个选项卡带有一个片段,每个片段带有recyclerviews,java,android,android-fragments,android-recyclerview,android-viewpager2,Java,Android,Android Fragments,Android Recyclerview,Android Viewpager2,因此,我编写了一个带有幻灯片选项卡的示例应用程序(viewager2)。每个选项卡都有一个片段,每个片段都有一个带有适配器的recyclerView。视图、使用滑动功能删除项目以及使用刷新功能的FAB按钮在每个recyclerviews的每个选项卡中都正常工作,但单击有问题,使用CAB长时间单击以删除多个项目无法正常工作。当我单击第一个选项卡时,它会工作当我单击第二个选项卡,然后单击第三个选项卡,然后返回到第一个选项卡时,多选项会工作,但删除不会工作。它仅删除最后一个选项卡片段的recycler

因此,我编写了一个带有幻灯片选项卡的示例应用程序(viewager2)。每个选项卡都有一个片段,每个片段都有一个带有适配器的recyclerView。视图、使用滑动功能删除项目以及使用刷新功能的FAB按钮在每个recyclerviews的每个选项卡中都正常工作,但单击有问题,使用CAB长时间单击以删除多个项目无法正常工作。当我单击第一个选项卡时,它会工作当我单击第二个选项卡,然后单击第三个选项卡,然后返回到第一个选项卡时,多选项会工作,但删除不会工作。它仅删除最后一个选项卡片段的recyclerview数据上的值,即使它显示第一个选项卡数据。不知何故,我丢失了以前生成的适配器、数据等。可能是我没有将数据正确地连接到适配器。(应用程序从主活动中的string.xml读取数据作为全局数据。) (提前感谢您的帮助。) 我试图追踪这个程序。 在click和longclick内的片段中,如果我检查视图,则会很好地显示数据,但如果我访问适配器数据,则会显示recyclerview的最后(3.)个数据,并且即使我在第一个选项卡中选择了第一个recyclerview,也会从中删除数据

以下是想要尝试的代码:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final Head head = (Head) getApplicationContext();
    inic_Head(head);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle("Haho!");

    TabLayout tabLayout = findViewById(R.id.tab_layout);
    ViewPager2 viewPager = findViewById(R.id.pager);

    // viewPager.setPageTransformer(new ZoomOutPageTransformer());
    // viewPager.setPageTransformer(new DepthPageTransformer());
    FragmentStateAdapter pagerAdapter = new DemoCollectionAdapter(this,head.get_MaxTabs());
    // FragmentStateAdapter pagerAdapter = new DemoCollectionAdapter(this,2);
    viewPager.setAdapter(pagerAdapter);

    new TabLayoutMediator(tabLayout, viewPager,
            new TabLayoutMediator.TabConfigurationStrategy() {
                @Override
                public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                    tab.setText("OBJECT " + (position));
                }
            }).attach();

}


void inic_Head(Head head) {
    String[] titles;

    // int a = R.array.htmls0;

    head.set_MAX_TABS(3);

    titles = getResources().getStringArray(R.array.titles0);

    head.clear_V(0);
    head.full_fill_V(0,titles);

    titles = getResources().getStringArray(R.array.titles1);

    head.clear_V(1);
    head.full_fill_V(1,titles);

    titles = getResources().getStringArray(R.array.titles2);

    head.clear_V(2);
    head.full_fill_V(2,titles);
}


public static class DemoCollectionAdapter extends FragmentStateAdapter {
    int tabsize;

    /*
    public DemoCollectionAdapter(Fragment fragment) {
        super(fragment);
    }
     */

    public DemoCollectionAdapter(@NonNull FragmentActivity fragmentActivity,int tabsize) {
        super(fragmentActivity);

        this.tabsize=tabsize;
    }

    @Override
    public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
        super.onAttachedToRecyclerView(recyclerView);
    }


    @NonNull
    @Override
    public Fragment createFragment(int position) {
        // Return a NEW fragment instance in createFragment(int)
        // Bundle args = new Bundle();
        // Our object is just an integer :-P
        // args.putInt(DemoObjectFragment.ARG_OBJECT, position + 1);
        // fragment.setArguments(args);
        return DemoObjectFragment.newInstance(position);
    }



    @Override
    public int getItemCount() {
        return tabsize;
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.toolbar_menu, menu);

    // return super.onCreateOptionsMenu(menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {

    switch(item.getItemId()){
        case R.id.menuRefresh:
            Toast.makeText(this, "You clicked: Refresh", Toast.LENGTH_SHORT).show();
            // inic_Head(head);
            break;

        case R.id.menuExit:
            Toast.makeText(this, "You clicked: Exit", Toast.LENGTH_SHORT).show();
            moveTaskToBack(true);
            android.os.Process.killProcess(android.os.Process.myPid());
            System.exit(0);
            break;

    }


    // return super.onOptionsItemSelected(item);
    return true;
}
}

片段:

public class DemoObjectFragment extends Fragment {
RecyclerView recyclerView;
ArrayList<HtmlsCatD> htmlsCatDal;
HtmlsCatDsAdapter htmlsCatDsAdapter;
private ActionModeCallback actionModeCallback = new ActionModeCallback();
private ActionMode actionMode;

private int[] COLOR_MAP = {
        R.color.red_100, R.color.red_300, R.color.red_500, R.color.red_700, R.color.blue_100,
        R.color.blue_300, R.color.blue_500, R.color.blue_700, R.color.green_100, R.color.green_300,
        R.color.green_500, R.color.green_700
};

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
// private static final String ARG_PARAM1 = "param1";
// private static final String ARG_PARAM2 = "param2";
private static final String ARG_OBJECT = "object";

// TODO: Rename and change types of parameters
// private String mParam1;
// private String mParam2;
private int mObject;

public DemoObjectFragment() {
    // Required empty public constructor
}

/**
 * Use this factory method to create a new instance of
 * this fragment using the provided parameters.
 *
 * // @param param1 Parameter 1.
 * // @param param2 Parameter 2.
 * @return A new instance of fragment DemoObjectFragment.
 */
// TODO: Rename and change types and number of parameters
/*
public static DemoObjectFragment newInstance(String param1, String param2) {
    DemoObjectFragment fragment = new DemoObjectFragment();
    Bundle args = new Bundle();
    args.putString(ARG_PARAM1, param1);
    args.putString(ARG_PARAM2, param2);
    fragment.setArguments(args);
    return fragment;
}
 */

public static DemoObjectFragment newInstance(Integer object) {
    DemoObjectFragment fragment = new DemoObjectFragment();
    Bundle args = new Bundle();
    // args.putString(ARG_PARAM1, param1);
    // args.putString(ARG_PARAM2, param2);
    args.putInt(ARG_OBJECT, object);
    fragment.setArguments(args);
    return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        // mParam1 = getArguments().getString(ARG_PARAM1);
        // mParam2 = getArguments().getString(ARG_PARAM2);
        mObject = getArguments().getInt(ARG_OBJECT);
    }
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment

    View fragmentView = inflater.inflate(R.layout.fragment_demo_object, container, false);

    recyclerView = fragmentView.findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    // Grid:
    // recyclerView.setLayoutManager(new GridLayoutManager(requireContext(),4));
    recyclerView.setHasFixedSize(true);
    recyclerView.setBackgroundColor(ContextCompat.getColor(Objects.requireNonNull(getContext()), COLOR_MAP[mObject]));

    // Head.clear_all();
    // HtmlsCatDsAdapter htmlsCatDsAdapter = new HtmlsCatDsAdapter(requireContext(), Head.getHtmlsCatDal());

    htmlsCatDal = new ArrayList<>();

    // HtmlsCatDsAdapter htmlsCatDsAdapter = new HtmlsCatDsAdapter(requireContext(), Head.getHtmlsCatDal());
    htmlsCatDsAdapter = new HtmlsCatDsAdapter(requireContext(), htmlsCatDal);
    recyclerView.setAdapter(htmlsCatDsAdapter);


    ItemTouchHelper helper = new ItemTouchHelper(new ItemTouchHelper.SimpleCallback(
            ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT |
                    ItemTouchHelper.DOWN | ItemTouchHelper.UP,
            ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {

        @Override
        public boolean onMove(@NonNull RecyclerView recyclerView,
                              @NonNull RecyclerView.ViewHolder viewHolder,
                              @NonNull RecyclerView.ViewHolder target) {

            int from = viewHolder.getAdapterPosition();
            int to = target.getAdapterPosition();
            Collections.swap(htmlsCatDal, from, to);
            htmlsCatDsAdapter.notifyItemMoved(from, to);

            return true;
        }

        @Override
        public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder,
                             int direction) {
            htmlsCatDal.remove(viewHolder.getAdapterPosition());
            htmlsCatDsAdapter.notifyItemRemoved(viewHolder.getAdapterPosition());

        }
    });

    helper.attachToRecyclerView(recyclerView);

    htmlsCatDsAdapter.setOnItemClickListener(new HtmlsCatDsAdapter.ClickListener() {

        @Override
        public void onItemClick(View v, int position) {

            HtmlsCatD htmlsCatD = htmlsCatDsAdapter.getHtmlsCatDal().get(position);
            String title = htmlsCatD.getTitle();
            Toast.makeText(getContext(), "On Click\nPosition : " + position + "\nTitle : " + title + " " + mObject, Toast.LENGTH_SHORT).show();
            // HtmlsCatD  htmlsCatD = htmlsCatDsAdapter.getItem(position);
            // Toast.makeText(getContext(), "On Click\nPosition : " + position + " " + htmlsCatD.getTitle(), Toast.LENGTH_SHORT).show();
            TextView textView = v.findViewById(R.id.title);
            Toast.makeText(getContext(), "On Click\nPosition : " + position + " " + textView.getText(), Toast.LENGTH_SHORT).show();

            if (actionMode != null) {
                toggleSelection(position);
            }
            // else { mAdapter.removeItem(position); }
        }

        @Override
        public boolean onItemLongClick(View v, int position) {

            // HtmlsCatD htmlsCatD = htmlsCatDsAdapter.getHtmlsCatDal().get(position);
            // String title = htmlsCatD.getTitle();
            //  Toast.makeText(getContext(), "On Long Click\nPosition : " + position + "\nTitle : " + title, Toast.LENGTH_SHORT).show();
            TextView textView = v.findViewById(R.id.title);
            Toast.makeText(getContext(), "On Click\nPosition : " + position + " " + textView.getText(), Toast.LENGTH_SHORT).show();


            if (actionMode == null) {
                actionMode = Objects.requireNonNull(getActivity()).startActionMode(actionModeCallback);
            }

            toggleSelection(position);

            return false;
        }

    });

    final Head head = (Head) Objects.requireNonNull(getActivity()).getApplicationContext();
    htmlsCatDal.addAll(head.getHtmlsCatDalm_V(mObject));
    /*
    for (int i = 0; i < head.get_size_V(mObject); i++) {
        htmlsCatDal.add(head.getHtmlsCatD(mObject,i));
    }
     */
    htmlsCatDsAdapter.notifyDataSetChanged();


    FloatingActionButton fab = fragmentView.findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            htmlsCatDal.clear();
            htmlsCatDal.addAll(head.getHtmlsCatDalm_V(mObject));
            /*
            for (int i = 0; i < head.get_size_V(mObject); i++) {
                htmlsCatDal.add(head.getHtmlsCatD(mObject,i));
            }
             */
            htmlsCatDsAdapter.notifyDataSetChanged();
        }
    });

    // return inflater.inflate(R.layout.fragment_demo_object, container, false);
    return fragmentView;
}

private void toggleSelection(int position) {
    htmlsCatDsAdapter.toggleSelection(position);
    int count = htmlsCatDsAdapter.getSelectedItemCount();

    if (count == 0) {
        actionMode.finish();
    } else {
        actionMode.setTitle(String.valueOf(count));
        actionMode.invalidate();
    }
}


private class ActionModeCallback implements ActionMode.Callback {

    @Override
    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        mode.getMenuInflater().inflate(R.menu.selected_menu, menu);
        return true;
    }

    @Override
    public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
        return false;
    }

    @Override
    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_remove:
                // TODO: actually remove items
                htmlsCatDsAdapter.removeItems(htmlsCatDsAdapter.getSelectedItems());
                Log.d("Here", "menu_remove");
                mode.finish();
                return true;

            default:
                return false;
        }
    }

    @Override
    public void onDestroyActionMode(ActionMode mode) {
        htmlsCatDsAdapter.clearSelection();
        actionMode = null;
    }
}

/*
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Bundle args = getArguments();
    assert args != null;
    // ((TextView) view.findViewById(android.R.id.text1)).setText(args.getInt(ARG_OBJECT));
    ((TextView) fragmentView.findViewById(android.R.id.text1)).setText("1");
}
 */
}

数据结构:

public class Head extends HtmlsCatD {
private int MAX_TABS;
private ArrayList<ArrayList<HtmlsCatD>> htmlsCatDalm;

public Head() {
    super();
    htmlsCatDalm = new ArrayList<>(MAX_TABS);
    ArrayList<HtmlsCatD> htmlsCatDal0 = new ArrayList<>();
    ArrayList<HtmlsCatD> htmlsCatDal1 = new ArrayList<>();
    ArrayList<HtmlsCatD> htmlsCatDal2 = new ArrayList<>();
    htmlsCatDalm.add(htmlsCatDal0);
    htmlsCatDalm.add(htmlsCatDal1);
    htmlsCatDalm.add(htmlsCatDal2);
}

public void set_MAX_TABS(int MAX_TABS) {
    this.MAX_TABS = MAX_TABS;
}

public int get_MaxTabs() {
    return MAX_TABS;
}

public ArrayList<HtmlsCatD> getHtmlsCatDalm_V(int i) { return htmlsCatDalm.get(i); }

public HtmlsCatD getHtmlsCatD(int i,int j) { return htmlsCatDalm.get(i).get(j); }


public void clear_all() {
    htmlsCatDalm.clear();
}

public void clear_V(int i) {
    htmlsCatDalm.get(i).clear();
}


public void full_fill_V(int i,String[] titles) {

    for (int j = 0; j < titles.length; j++) {
        htmlsCatDalm.get(i).add(new HtmlsCatD(titles[j]));
    }
}


public int get_size() { return htmlsCatDalm.size(); }

public int get_size_V(int i) { return htmlsCatDalm.get(i).size(); }


@NonNull
@Override
public String toString() {
    return "Head{}";
}
公共类头扩展HtmlsCatD{
专用int MAX_选项卡;
私有数组列表htmlsCatDalm;
公共主管(){
超级();
htmlsCatDalm=新阵列列表(最大选项卡);
ArrayList htmlsCatDal0=新的ArrayList();
ArrayList htmlsCatDal1=新的ArrayList();
ArrayList htmlsCatDal2=新的ArrayList();
添加(htmlsCatDal0);
添加(htmlsCatDal1);
添加(htmlsCatDal2);
}
公共无效集合最大选项卡(整数最大选项卡){
this.MAX\u TABS=MAX\u TABS;
}
public int get_maxtab(){
返回最大标签;
}
公共数组列表getHtmlsCatDalm_V(int i){返回htmlsCatDalm.get(i);}
公共HtmlsCatD getHtmlsCatD(inti,intj){返回htmlsCatDalm.get(i).get(j);}
公共无效清除所有(){
htmlsCatDalm.clear();
}
公共空间清理(内部一){
htmlsCatDalm.get(i.clear();
}
公共空白完全填充(整数i,字符串[]标题){
对于(int j=0;j
}

Strings.xml:

<resources>
<string name="app_name">PagerFragS0</string>

<string-array name="titles0">
    <item>PAGE 0 DATA 0</item>
    <item>PAGE 0 DATA 1</item>
    <item>PAGE 0 DATA 2</item>
    <item>PAGE 0 DATA 3</item>
    <item>PAGE 0 DATA 4</item>
    <item>PAGE 0 DATA 5</item>
</string-array>

<string-array name="titles1">
    <item>PAGE 1 DATA 0</item>
    <item>PAGE 1 DATA 1</item>
    <item>PAGE 1 DATA 2</item>
    <item>PAGE 1 DATA 3</item>
    <item>PAGE 1 DATA 4</item>
    <item>PAGE 1 DATA 5</item>
    <item>PAGE 1 DATA 6</item>
    <item>PAGE 1 DATA 7</item>
    <item>PAGE 1 DATA 8</item>
    <item>PAGE 1 DATA 9</item>
    <item>PAGE 1 DATA 10</item>
</string-array>

<string-array name="titles2">
    <item>PAGE 2 DATA 0</item>
    <item>PAGE 2 DATA 1</item>
    <item>PAGE 2 DATA 2</item>
    <item>PAGE 2 DATA 3</item>
    <item>PAGE 2 DATA 4</item>
    <item>PAGE 2 DATA 5</item>
    <item>PAGE 2 DATA 6</item>
    <item>PAGE 2 DATA 7</item>
    <item>PAGE 2 DATA 8</item>
    <item>PAGE 2 DATA 9</item>
    <item>PAGE 2 DATA 10</item>
    <item>PAGE 2 DATA 11</item>
    <item>PAGE 2 DATA 12</item>
</string-array>

<!-- TODO: Remove or change this placeholder text -->
<string name="title_placeholder">Title</string>

寻呼机0
第0页数据0
第0页数据1
第0页数据2
第0页数据3
第0页数据4
第0页数据5
第1页数据0
第1页数据1
第1页数据2
第1页数据3
第1页数据4
第1页数据5
第1页数据6
第1页数据7
第1页数据8
第1页数据9
第1页数据10
第2页数据0
第2页数据1
第2页数据2
第2页数据3
第2页数据4
第2页数据5
第2页数据6
第2页数据7
第2页数据8
第2页数据9
第2页数据10
第2页数据11
第2页数据12
标题
activity.main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".MainActivity">

<androidx.appcompat.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

<com.google.android.material.tabs.TabLayout
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/toolbar"
    android:background="?attr/colorPrimary"
    android:minHeight="?attr/actionBarSize"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:tabMode="scrollable" />

<androidx.viewpager2.widget.ViewPager2
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/tab_layout" />

fragment_demo.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".DemoObjectFragment">

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:scrollbars="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    app:srcCompat="@drawable/ic_reset"
    />

list_items.xml:

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_gravity="center"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="@color/lightBlue"
card_view:cardCornerRadius="0dp">

<LinearLayout
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/title"
        style="@style/TextAppearance.AppCompat.Headline"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_marginStart="8dp"
        android:scaleType="centerCrop"
        android:textSize="12sp"
        android:text="@string/title_placeholder" />


</LinearLayout>

<View
    android:id="@+id/selected_overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/selected_overlay"
    android:visibility="invisible" />

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".DemoObjectFragment">

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/recyclerView"
    android:scrollbars="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    app:srcCompat="@drawable/ic_reset"
    />
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_gravity="center"
android:foreground="?android:attr/selectableItemBackground"
app:cardBackgroundColor="@color/lightBlue"
card_view:cardCornerRadius="0dp">

<LinearLayout
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/title"
        style="@style/TextAppearance.AppCompat.Headline"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:layout_marginStart="8dp"
        android:scaleType="centerCrop"
        android:textSize="12sp"
        android:text="@string/title_placeholder" />


</LinearLayout>

<View
    android:id="@+id/selected_overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/selected_overlay"
    android:visibility="invisible" />