There are many solutions for side-sliding deletion on the Internet, such as rewriting Listview to implement sliding monitoring. Today I will talk about the next SwipeListView. This is an encapsulated component that a friend opened the source online. It can be used in many situations. Project address:/baoyongzhang/SwipeMenuListView, I also used the use of the principle of using it directly.
However, when the data was deleted by sliding the debugging run, a problem occurred. The location of the deleted position was inconsistent. The first data was deleted, but the last one was deleted. So I looked for the problem. I first tried it with listview. There was no problem with the data. It means that the control deleted during the deletion was incorrect in the calculation of the position. Let’s take two renderings first.
So what is the problem? I looked at a previously submitted version (I remember that it was good before, which means it was a recently submitted problem. So I found a problem, that is, the getview method of the SwipeMenuAdapter class has an extra judgment than before. In order to cache the added ones, the judgment condition is removed by trying, and then run it. OK, some code is posted here.
public View getView(int position, View convertView, ViewGroup parent) { SwipeMenuLayout layout = null; // if (convertView == null) { View contentView = (position, convertView, parent); SwipeMenu menu = new SwipeMenu(mContext); (getItemViewType(position)); createMenu(menu); SwipeMenuView menuView = new SwipeMenuView(menu, (SwipeMenuListView) parent); (this); SwipeMenuListView listView = (SwipeMenuListView) parent; layout = new SwipeMenuLayout(contentView, menuView, (), ()); (position); // } else { // layout = (SwipeMenuLayout) convertView; // (); // (position); //// View view = (position, (), //// parent); // } if (mAdapter instanceof BaseSwipListAdapter) { boolean swipEnable = (((BaseSwipListAdapter) mAdapter).getSwipEnableByPosition(position)); (swipEnable); } return layout; }
The above is a bug that I have recorded in Android development that SwipeMenuListView side-sliding and removing confusing bugs. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!