Here if that image is clicked, it opens a new window. How to achieve this? Its not a Menu right??
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 .
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.
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();
}
});
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.