I have Listview. And I want to add overflow menu to each listview's item. How to do it? Now I add button to every item and show dropdown menu when user clicks on this button. But I want to replace this ordinary button with overflow one.
Add an ImageView or Button to trigger the menu on the right of your listview items. To get the "overflow" icon, see this question: How do I get a copy of the Android overflow menu icon?
Add an onClickListener to your ImageView or Button
On your onCreate() method, create a popup menu like this:
popupMenu = new PopupMenu(this, findViewById(R.id.anchor));
popupMenu.getMenu().add(...);
popupMenu.setOnMenuItemClickListener(this);
In your onClickListener trigger the display of the popup menu
popupMenu.show();
Related
I have a ListView in my layout. I have attached onItemClickListener for ListView to listen for item clicks. Whenever I will click on the item of it, a BottomSheetDialog will inflate. The problem is, that I want the content outside bottomsheetdialog to be clickable and scrollable. Whenever I inflate BottomSheetDialog, the content outside it becomes unresponsive. It doesn't respond to clicks, scroll etc. How can I make the content outside it to still be clickable and scrollable?
I am stuck in a project. I need to add items to my ListView through alert dialog box. like 1st item will act as a heading and when it is selected a dialog box will open and the value will be added as sub item of that ListView. I will attach pictures just the I want them to be. Please if anyone can help.
below is the picture of ODK app.
I am Creating a ImageViews dynamically now i need to display pop up menu if click the ImageView.
ex: In that pop up i will add download. If i click that download button respective Image should download.
I'm not very sure about putting a button on an imageview...take a look at this answer:
Put a button over an ImageView
As for making a popup appear on button click, use dialogfragments.
I have a webview and want to listen its loading event and I have a refresh button on my actionbar.
How to change the button to a spinner programmatically?
You can't magically change a button into a spinner. What you can do is disable the button and enable the spinner.
myButton.setEnabled(false);
mySpinner.setEnabled(true);
If you want to make the spinner take the place of the button, then you're going to have to put all of your layout drawing routine into a buildLayout() (or whatever you want to call it) and redraw the entire layout with a button or with a spinner, depending on the state of your application.
if I have an Options menu in Android that has more than 6 items, Android adds a More item that shows the other hidden items, AS text!
But I want the More button to display the extra items both in their text AND icon, how do I do that?
I think this is not possible, unless you code that by your self. And by "code" I mean you create a custom menu.