开发学院手机开发Android 开发 Android 长按setOnItemLongClickListener 显示con... 阅读

Android 长按setOnItemLongClickListener 显示context Menu

 2010-11-05 00:55:30 来源:WEB开发网   
核心提示:Android 长按setOnItemLongClickListener 显示context Menu(上下文菜单) 例子...Java代码private ListView fileList;private ListView fileList;Java代码fileList.setOnCreateContextMenuL

Android 长按setOnItemLongClickListener 显示context Menu(上下文菜单) 例子...

Java代码

private ListView fileList;

private ListView fileList;

Java代码

fileList

.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

@Override

public void onCreateContextMenu(ContextMenu menu, View v,

ContextMenuInfo info) {

// TODO Auto-generated method stub

menu.setHeaderTitle(R.string.contentMenu);

menu.add(0, AndBoxConstant.OPEN, 0, R.string.open);

menu.add(0, AndBoxConstant.PROPERTIY, 6,

R.string.properties);

}

});

fileList

.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

@Override

public void onCreateContextMenu(ContextMenu menu, View v,

ContextMenuInfo info) {

// TODO Auto-generated method stub

menu.setHeaderTitle(R.string.contentMenu);

menu.add(0, AndBoxConstant.OPEN, 0, R.string.open);

menu.add(0, AndBoxConstant.PROPERTIY, 6,

R.string.properties);

}

});

Java代码

fileList.setOnItemLongClickListener(new OnItemLongClickListener() {

@Override

public boolean onItemLongClick(AdapterView ada, View view,

int index, long longIndex) {

fileList.showContextMenu();

return true;

}

});

Tags:Android setOnItemLongClickListener 显示

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
更多精彩
    赞助商链接

    热点阅读
      焦点图片
        最新推荐
          精彩阅读