Created
May 12, 2012 15:37
-
-
Save kyuucr/2667195 to your computer and use it in GitHub Desktop.
Android - Hide context menu on certain ListView item.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleActivity extends ListActivity { | |
[...] | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
[...] | |
registerForContextMenu(mListView); | |
mListView.setOnItemLongClickListener(new OnItemLongClickListener() { | |
@Override | |
public boolean onItemLongClick(AdapterView<?> adapterView , View v,int position, long id) { | |
getListView().getItemAtPosition(position); //check current item with your logic and show or don't show contextMenu | |
// for example I will show | |
getListView().showContextMenu(); //to show | |
return true; | |
} | |
}); | |
} | |
[...] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment