Skip to content

Instantly share code, notes, and snippets.

@Richie97
Created June 27, 2012 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Richie97/3006339 to your computer and use it in GitHub Desktop.
Save Richie97/3006339 to your computer and use it in GitHub Desktop.
Custom View onClick
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.entry_menu, menu);
MenuItem mItem = menu.findItem(R.id.menu_comments);
commentCount = (TextView)mItem.getActionView().findViewById(R.id.actionEntryCommentCount);
commentCount.setText(Integer.toString(article.numComments));
mItem.getActionView().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(EntryActivity.this, CommentsActivity.class);
if (type == 1){
intent.putExtra("entryId", entryFrag.article.id);
}else{
intent.putExtra("entryId", article.id);
}
intent.putExtra("type", type);
startActivity(intent);
}
});
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment