I have searched a lot in SO, but didn't get similar type thread. In my application, i need to add or remove item in activity's layout when user clicks on listview's item. Listview displays data using a custom array adapter. If user clicks on an item then it will be added to the activity's layout and further clicks on the same item, it will be removed. I don't know how to accomplish this task. Any help will be appreciated in this context.
Here is an image:
I do not know what UI effect do you want.
1. If you want the top panel section in your image fixed(do not scroll) when scroll list, then you can:
Use a LinearLayout as root element
Add a LinearLayout as top panel
Add ListView below top panel
Create a selectedView.xml that you what add to top panel when click a item of ListView
When user clicks item of ListView, you can try code below:
ItemModel itemData = dataList.get(position)
// inflate selectItemView and add to top panel
View selectItemView= LayoutInflater.from(this).inflate(R.layout.selectedView, topPanelView, true);
View text1 = selectItemView.findViewById(xxx);
text1.setText(itemData.getxxx);
...
//inflate other field using itemData
...
If you want top panel scroll out of top when scroll ListView.
Make top panel as HeaderView of ListView and follow the part step of 1 and code.
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.
Following situation: I have a ListFragment, if you click on a list item of it some views inside the list item gets visible, so the list item itself gets expanded. Now, imagine the pressed list item is the last in the list, the expanded part won't be visible. Is there a way to achieve that the list scrolls down a little bit so the complete list item is visible?
Try this: yourListView.scrollTo(0, yourListView.getHeight());
I have a ListView and each item have a TextView.
I would like add a small icon when user click in that item. (when user click other, icon hide and show in the other)
any ideas, examples or tutorials?
thanks
You are going to need a custom ListViewAdapter. This website has a good tutorial:
http://www.ezzylearning.com/tutorial.aspx?tid=1763429
You could put an OnClickListener on each list item that associates the icon with that item and programmatically add the icon to its layout, while removing it from the previous' layout. So you'll want to have a variable that holds the current layout that is associated with the icon, and when a new item is clicked you remove the icon from that layout, then set the variable to this new item's layout.
I have used a button in all list items of a listview. I lost the list item click when i added a clickable componenet is list items of the list view. Now i need to add a button in listitems in of the listview and i added it. I need to have click event for both list items and also the buttons. How can i make is possible.
Please share.
Thanks in advance.
You'll have to attach click listeners to the internal views. Try to create a listener for each ViewHolder and recycle them just like you do for the views passed in to getView(). Note that you'll also have to attach a long click listener or explicitly disable long clicks on the new clickable subview or you will lose the context menu on the list item. Another thing to think about is how you intend to handle d-pad navigation with these sub-views.
I want to display a list item that says "More" at the end of my ListView. Clicking on this list-item will perform some action. How can I create this "more" list item?
I don't know about the "Clicking on this list-item will perform some action" part. The typical pattern is that once the user scrolls to the bottom, new material is loaded automatically. Some people do that by detecting the scroll. I do it by putting in a "More" placeholder and detecting when that is used. Here is a component that implements this pattern.
Just add another value to your arrayadapter (or any other adapter), you might be using.set the text to 'more' .
Suppose you have n items in the list then handle the (n+1)th postion click and do your stuff.
You can add a footer to your listview...
Did you check this post out?
Android ListView Footer View not being placed on the bottom of the screen