Selecting multiple items in ListView Android - android

I wish to select multiple ListView items and then share all of them. How can I go about it?

See the Awesome example here android-multiple-selection-listview

Well,
First you need to create OnItemClickListener(View v) in order to get clicks.
Then you can make a HashMap in order to preserve the items which are clicked.
You can also change the Background of the clicked item so the user will know which items are clicked.
Final thing you need is the action (button click - Share) which will pass through the HashMap and collect all clicked items. After that you can do with them what ever you want.
It looks like a huge work, but it's can easily divided into steps and you close them one by one... It actually quite simply.

I want that on the click of the option menu item in action bar, the listview's choice mode becomes multiple, which is easy to achieve. Simultaneously i want to inflate two options menu items namely "ok" and "cancel", so that once the user is done selecting some or all listview items, he can click on "ok" option menu to proceed.

Related

Android. RecyclerView with collapsing items

I need to create recyclerView with collapsing items. For example, I have a list of 10 items. By default, I only need to flip the first 2 elements. But by clicking on the "See all" button, I need to display all the items in the list. And vice versa, by clicking on the "Hide" button, you need to leave only the first two items in the list. Here is an example:
I suppose to implement it like this: create a flag that determines whether the full list is displayed or not, and by clicking on the button, depending on the flag, send the full list to the adapter or cut it to two elements and call notifyDataSetChanged().
But this solution seemed to me not very good, perhaps there is a more elegant solution.
Note: I don't need nested collapsing elements. I just need to display two items from a list or all items.
Please help me.

Android List item click horizontal menu

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.

Android open ListView for multiple selection programmatically

I got a fragment with a ListView. The purpose of the list is simply checking items in that list, so I want to add something to the onCreateView method which will make the list enter its multiple selection mode automatically as the fragment shows, without the need for the user to long press an item. How can I do that?
to use longpress , you can do this way,
android:choiceMode="multipleChoiceModal"
or
setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL)
go through this for more information

Android: Including a checkbox feature in a listview

I have a listview which contains names of people from my People class. I want to be able to mark multiple people and then delete marked for example.
I have read many questions and seen answers and I've decided I want to do it the following way for simplicity...
I just select the listItem, click on options menu and I select mark. Then a listener will set a private boolean in the person class, isMarked, to true, and then, to tell the user it is marked, a tick appears next to the listItem.
So the question is, is there a way to make an image appear and disappear in android?
EDIT: I have already implemented the options menu and selecting a person and selecting mark then making his/her marked variable true. What I basically need is an indicator to the user that that person is marked.
If what you want to do is have visual feedback for the item's status, then what you probably need is a custom view layout for the items in the ListView. When the list requests a view for the item (getView function) you can show/hide an image to indicate the item's status.
Check the documentation for Adapters, as there are a few other functions related to how this is done. You don't show in the question how you've set up the source of the ListView data.
However, as it seems that what you want to do is to select items and then perform actions on them, you should read on about contextual action bar (see the 'Using the contextual action bar'). Some more info in the menu's page, particularly in the 'Enabling batch contextual actions in a ListView or GridView' section. Selecting items one by one and using the menu to mark them seems like an non-android'y way of doing things.
So the question is, is there a way to make an image appear and disappear in android?
You need to get a reference to the view you want to show/hide and then use the following: http://developer.android.com/reference/android/view/View.html#setVisibility(int)
For example:
ImageView imageView = (ImageView) findViewById(R.id.myimageview);
if (isMarked) {
view.setVisibility(View.VISIBLE);
} else {
view.setVisibility(View.INVISIBLE);

How to display "More" list item in ListView?

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

Categories

Resources