Reputation: 2135
Here if that image is clicked, it opens a new window. How to achieve this? Its not a Menu right??
Upvotes: 0
Views: 353
Reputation: 6540
OnCreate
you need this.registerForContextMenu(mImageView);
use onClickListener
for mImageView
:
mImageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
v.performLongClick();
}
});
Implement the context menu http://developer.android.com/guide/topics/ui/menus.html#context-menu
Upvotes: 0
Reputation: 1872
try like this.
mImageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(
ctContext);
builder.setItems(listdatatopopulate,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialogInterface,
int item) {
// do some thing on item click
}
});
builder.create().show();
}
});
Upvotes: 0
Reputation: 157487
View
's can trigger the onClick(View v)
callback if you set the OnClickListener
upon them. When the callback is invoked, you can simply switch trough View.getId(), in order to understand which View
has been clicked. If the view
's clicked is the right one, instantiate and show your dialog.
Upvotes: 0
Reputation: 22038
You can set an onClickListener on the ImageView like
mImageView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// start a dialog
}
});
On click, you open a dialog http://developer.android.com/guide/topics/ui/dialogs.html.
Upvotes: 1