我正在使用baoyongzhang的SwipeMenuListView库,但是当我向左滑动时,这些项不会停滞不前,并且listview关闭。这是SwipeMenuCreator的代码
SwipeMenuCreator creator = new SwipeMenuCreator() {
@Override
public void create(SwipeMenu menu) {
SwipeMenuItem openItem = new SwipeMenuItem(
getApplicationContext());
// set item background
openItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9,
0xCE)));
// set item width
openItem.setWidth(170);
// set item title
openItem.setTitle("Open");
// set item title fontsize
openItem.setTitleSize(18);
// set item title font color
openItem.setTitleColor(Color.WHITE);
// add to menu
menu.addMenuItem(openItem);
SwipeMenuItem deleteItem = new SwipeMenuItem(
getApplicationContext());
deleteItem.setBackground(new ColorDrawable(Color.rgb(0xF9,
0x3F, 0x25)));
deleteItem.setWidth(170);
deleteItem.setIcon(R.drawable.ic_delete_forever_black_24dp);
menu.addMenuItem(deleteItem);
}
};
timeListView.setMenuCreator(creator);
这是当您滑动列表视图时的代码
timeListView.setOnMenuItemClickListener(new SwipeMenuListView.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(int position, SwipeMenu menu, int index) {
switch (index) {
case 0:
Toast.makeText(MainActivity.this, "Case 0", Toast.LENGTH_SHORT).show();
break;
case 1:
Toast.makeText(MainActivity.this, "Case 1", Toast.LENGTH_SHORT).show();
break;
}
return false;
}
});