Skip to content

Commit

Permalink
第5章 高级控件
Browse files Browse the repository at this point in the history
  • Loading branch information
aqi00 committed Feb 25, 2020
1 parent db01bca commit b9636f6
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, l
private Runnable mPopupMenu = new Runnable() {
@Override
public void run() {
// 取消lv_cart的点击监听器
lv_cart.setOnItemClickListener(null);
// 取消lv_cart的长按监听器
lv_cart.setOnItemLongClickListener(null);
// 注册列表项视图的上下文菜单
Expand All @@ -136,6 +138,12 @@ public void run() {
openContextMenu(mCurrentView);
// 注销列表项视图的上下文菜单
unregisterForContextMenu(mCurrentView);
// 构建购物车商品列表的适配器对象
CartAdapter adapter = new CartAdapter(ShoppingCartActivity.this, mCartArray);
// 给lv_cart设置商品列表适配器
lv_cart.setAdapter(adapter);
// 重新设置lv_cart的点击监听器
lv_cart.setOnItemClickListener(ShoppingCartActivity.this);
// 重新设置lv_cart的长按监听器
lv_cart.setOnItemLongClickListener(ShoppingCartActivity.this);
}
Expand Down

0 comments on commit b9636f6

Please sign in to comment.