[英]How to add checkbox on all the listView items after having a long item click? Android Java
I want to add a feature on my project where if the user clicks one of the items on the listView then a checkbox would appear allowing the user to delete 1 or many items at once.我想在我的项目中添加一个功能,如果用户单击 listView 上的项目之一,则会出现一个复选框,允许用户一次删除 1 个或多个项目。 Similar to Samsung Notes when you want to delete notes and or folders, etc. However, this concept is completely foreign to me and currently, I don't know where to begin to start this or what topic/resource/sample code I should look for.
当你想删除笔记和/或文件夹等时,类似于三星笔记。但是,这个概念对我来说是完全陌生的,目前,我不知道从哪里开始或者我应该看什么主题/资源/示例代码为了。 Also, I have a custom Array Adapter class that I used to order to work with my ListView but it came to my knowledge that you only need 1 array adapter class to make this work which made me confused since I don't know where to begin to manipulate it even further.
此外,我有一个自定义数组适配器类,我曾经订购它来使用我的 ListView,但据我所知,您只需要 1 个数组适配器类即可完成这项工作,这让我感到困惑,因为我不知道从哪里开始进一步操纵它。 Any help would be amazing!
任何帮助都会很棒!
Here is my Array Adapter that I have at the moment这是我目前拥有的阵列适配器
//want to create our own custom ArrayAdapter. Going to extends the base class ArrayAdapter and hold our
//Word object
public class WordAdapter extends ArrayAdapter<WordFolder> {
//constructor - it takes the context and the list of words
WordAdapter(Context context, ArrayList<WordFolder> word){
super(context, 0, word);
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
View listItemView = convertView;
if(listItemView == null){
listItemView = LayoutInflater.from(getContext()).inflate(R.layout.folder_view, parent, false);
}
//Getting the current word
WordFolder currentWord = getItem(position);
//making the 3 text view to match our word_folder.xml
TextView date_created = (TextView) listItemView.findViewById(R.id.date_created);
TextView title = (TextView) listItemView.findViewById(R.id.title);
TextView desc = (TextView) listItemView.findViewById(R.id.desc);
//using the setText to get the text and set it in the textView
date_created.setText(currentWord.getDateCreated());
title.setText(currentWord.getTitle());
desc.setText(currentWord.getTitleDesc());
return listItemView;
}
}```
In R.layout.folder_view add one and make it invisible or gone.在 R.layout.folder_view 中添加一个并使其不可见或消失。 OnLongClick make them Visible.
OnLongClick 使它们可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.