In my android application I have a list view and some other buttons above the listview. I need to implement the functionality to add the selected item of the listview to my favourites list by creating a menu item.
I can create a menu item to click and add the functionality.
But it should only show the menu item if the focus is on any listview item and not when the focus is on any other button or anyItem. the menu item should only display when the focus is on any listview item and press the menu button.
Can Someone help me please.
Have you considered using a context menu instead of trying to modify the main menu? It seems like behavior might be more in line with the UI guidelines.
Related
The attached UI is the calllog. What i am interested is that how the horizontal menu is implemented. When click on one list item, it appeared in one line under the list item.
In the earlier android, one click on list item, we can use Context menu popup menu to show the available action to do.
I am curious that it is using expandable list view concept?
I want to design like that when click on list item to show like this, but my layout would not be the same as this one. I want to put custom layout depending on the list item type. It may include button, textview, other widgets and the layout height will not be the list item height.
Can someone give some suggestion? Thanks a lot.
I have a GridView with some items and when the user clicks on an item, I show a DialogFragment with all the item details. I wanted to know if there is a way to create my own dropdown menu like the ones in the ActionBar. Meaning, when the user will click on an ImageButton let's say, I would show all the available actions for this item, like deletion, editing etc.
Any ideas are welcomed.
you could try PopupMenu. PopupMenu could be used to display a custom dropdown menu which could be anchored to a view
https://developer.android.com/reference/android/widget/PopupMenu.html
I have a ListView on my Android project, and when the item clicked, it will go to the "selected item detail info" activity. And when one of the item on hold, i want it to inflate or to pop up a context menu, it just like the one in some music player list.
I have no idea which event method that I should override to catch the onHold event of that listItem. Please somebody show me the way.
You should set on your ListView an OnItemLongClickListener.
If you are using ActionBar it would also be nice to set the ActionBar in ActionMode when an item is selected. For a quick tutorial for ActionMode you can check Vogella's List Tutorial.
I am developing an android application using a ListViewas a main interface. Each item in the List contains TextView and Button. When the Button is visible the item selection does not work and when the button is not visible the item selection work without problem. This problem is not reproduced if I change the button by an ImageView.
Is there a solution to make the item selection work when the Button is visible?
Directly we can't set the click option for both List item and the Button. So we have to use the custom adapter.
Try this example : http://code.google.com/p/codemobiles/source/browse/CustomListViewDemo/
Click is not working on the Listitem Listview android
Hi in my application I need to add Some menu items. The problem is, one menu item should only display when the focus is on one of the listview items.
Simply one of the menu items should only display if the focus is on at one the of the listview items. When the focus is at anywhere else then should display only the other menu items except that. Other menu items will display always.
I can track the focus. I tried to run following code only when focus is on listview.
menu.add(0, Menu.FIRST, 0, "Add to favourite List"); [Problem: if I press menu button more than one time while focus there it creates new menu item each time when I press the menu button.]
I am inflating from xml menu and create others.
Can anyone guide me how to do this... Thanks
use onPrepareOptionsMenu method and clear all menu first using
menu.clear();
then add menu.
You could have a variable to keep track of whether that menu item was added or not.