kidgenius
kidgenius

Reputation: 11

ContextMenu wont open with listview longClick

    registerForContextMenu(listView);



}
public void OnCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo){
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(R.id.item1);
    menu.add(R.id.item2);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.context_menu,  menu);

}
@Override
public boolean onContextItemSelected(MenuItem item){
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch(item.getItemId()){
    case R.id.item1:
        Intent smsIntent = new Intent(Intent.ACTION_VIEW);
        smsIntent.putExtra("sms_body",  "TU-Do List Item: " + mAdapter.getItem((int)info.id));
        smsIntent.putExtra("address",  "2924699");
        smsIntent.setType("vnd.android-dir/mms-sms");
        startActivity(smsIntent);
        return true;
    case R.id.item2:
        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,  "[email protected]");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,  "New TU-Do Item");
        emailIntent.setType("plain/text");
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,  mAdapter.getItem((int)info.id));
        startActivity(emailIntent);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

So i put that code for my android application

I dont understand why when i longclick my listview the contextMenu still wont pop up. Any help would be greatly appreciated

okay since that was super easy also some help with adding an onClickListener that works as well would be appreciated.

Upvotes: 0

Views: 65

Answers (1)

sergej shafarenka
sergej shafarenka

Reputation: 20426

onCreateContextMenu has to be written with small letter.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)...

Upvotes: 1

Related Questions