can't show contextmenu
This is my application and you can see that I make a list of data ,have 2 list each list contain 2 line and 1 imagebutton and I want to make a ContextMenu ( whan I press on each list it will show a ContextMenu)
I have coded about onCreateContextMenu like this...
@Override
    public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
            menu.add(0, EDIT_ID, 0, R.string.menu_edit);
        menu.add(0, DELETE_ID, 0, R.string.menu_delete);
    }
@Override
    public boolean onContextItemSelected(MenuItem item){
        switch(item.getItemId()){
        case EDIT_ID:{
            Cursor cc = cursor;
            Intent edit_Im_Sens = new Intent(Im_SensShow.this,Im_SensEdit.class);
    开发者_JS百科        Bundle bundle = new Bundle();
            bundle.putLong("THIMSENSID", thim_sens_id);
            bundle.putLong("IMSENSID", cc.getLong(cc.getColumnIndexOrThrow(DBAdapter.KEY_IM_SENS_ID)));
            bundle.putLong("LANGSID", cc.getLong(cc.getColumnIndexOrThrow(DBAdapter.KEY_LANGS_ID)));
            bundle.putString("IMSENS",cc.getString(cc.getColumnIndexOrThrow(DBAdapter.KEY_IM_SENS)));
            bundle.putString("READING",cc.getString(cc.getColumnIndexOrThrow(DBAdapter.KEY_READING)));
            edit_Im_Sens.putExtras(bundle);
            startActivityForResult(edit_Im_Sens,1);
            //return true;
            break;
            }
but it doesn't work ,it doesn't show a ContextMenu please help....
did you register the list view for context menu ?
registerForContextMenu(your_list)
// get the list view
ListView list = (ListView)findViewById(R.id.list);
// set adapter before registering the context menu
list.setAdapter(adapter);
// register it for the context menu
registerForContextMenu(list);
http://www.mikeplate.com/show-a-context-menu-for-long-clicks-in-an-android-listview/
 加载中,请稍侯......
      
精彩评论