Good day all,
I have a list of items that i want the user to be able select say 5 out of the 10 items and with all 5 be able to send some data off to a webservice.
i found This and This
but neither of them worked or the GitHub Repo is non existent (the second one).
Does anyone have any other tuts on how to do this?
Thank you
What is going on with your proplem?
Is the video (https://www.youtube.com/watch?v=7du30yAL6rI) as your expectation?
In this example, I create an empty class and simple recyclerview.
The view item will handle user click behaviour. If user selected item the click again the item would not select and otherwise. When this action is happening, we have a listener to send to MainActivity (implemented onItemChangeListener a method of interface that is defined in adapter)
In the MainActivity, I create a layout with recyclerView, delete button, and no items labels. The delete button will process delete and update the list data.
The source code is at: https://github.com/liemvo/Example_RecycleMultiSelected
Related
For example i have an app to make a shopping list.First activity shows the content of the list.Second one is to add items to the list and it has textviews and button.I used textviews to add items to the list.If you click any textview, related item is added to the shopping list.But you need to click the button to go without adding anything.And i am using an intent for this but if i click that button everything i added the list earlier is deleted.What is the problem and solution(s)?ty
Pls add code ..
however I think the problem can be solved if you need to pass all the data to the 2nd activity and rcv the intent...and when you set the onclick listener for the button in 2nd activity...all data need to be passed back with the intent and set on the list.
If you add the code it will help
I have an ExpandableListView implementation in my application and I am writing unit tests for it. I'm wondering how I can programmatically perform a click on the child view of an expandable header?
This is NOT a question about how to attach onChildClickListener() to the view. I've found many questions regarding that topic, but I already have that implemented and need to test the functionality of that code when the child view is clicked. I know that I can use the performClick() method to click on the header view to expand/collapse the contents, but I need to perform a click on the sublist of a header.
You can try with:
listView.setSelection(position);
but you have to consider this:
If in touch mode, the item will not be selected but it will still be
positioned appropriately. If the specified selection position is less
than 0, then the item at position 0 will be selected.
For more information you can visit the doc page.
I hope it helps.
Edit
As #RyanM appointed, setSelection just change the selection, but it doesn't perform the "click" action. You can perform the action through the function:
listView.performItemClick(goalListView, itemPosition, itemId);
You can find this function in the class AdapterView.
Sorry for the previous mistake to your answer.
I have an app that shows news from a RSS feed. There is ListView-1 which loads the news and when you click on an item(news), it shows only the selected news in a seperated xml layout. On the ActionBar for the single news item layout, user can click on Add to Favourites.
I have another activity and layout file and a listview just for Favourites. How can I copy an item from one listview to another?
So, the user can add news from main ListView-1 to another list called ListView-2.
I cannot use intents for sending one list item.
I have been thinking of using SharedPreferences to share an ArrayList, but something else needs to be the solution.
You don't need intents, just separate view and data, keep news in the singleton class, for example NewsManager, and keep one list for all news, one for favourite news, and use favourite list in the ListView2 adapter
I have a ListView with a header and a footer. I added two items with a class of my own extending the ArrayAdapter class. In this extended class, I have overridden the getView function because I want Views which are not TextViews to appear in my ListView.
On this ListView, I have set an onClickListener.
The problem is that this onClickListener is started when I click either on the header or on the footer, but never when I click on my items.
Of course, the View returned by getView is set to be clickable.
What am I missing?
Do you want to do something different when each list element is clicked? If so, you should programmatically set an onClickListener for each of those 2 elements added. Can you post your code?
It sounds like you are making this much more complicated than necessary. You can create your own layout for each row of a ListView using an XML file. This allows you to use any combinations of Views that you wish. To control what happens when the user clicks on a row in the ListView, your activity class should extend ListActivity and override onItemClickListener(). Alternatively, you can call setOnItemClickListener() on your ListView. For more details, I suggest that you read the Android ListView Developer Guide.
The solution I found : the click listener attached to the 'ListView' is only used for the clicks on the header and the footer. For my custom rows, in my ArrayAdapter's 'getView' function, I attached one listener to the 'TextView' and another to the 'ImageButton'.
I have been thinking about adding a button to a View which when pressed adds another view on the bottom. It would resemble the Clock application that comes preinstalled in which you push a view in form of an alarm which is then added to a list.
Does anyone have any experience with how to implement that?
Have a look at the documentation for ListView, particularly the setAdapter() method. You'll want to have some sort of backing collection most likely as the adapter, such as an ArrayAdapter, to which you can add new items, and have them populate into the list.
Use a listview, populate it.
Then when you press the button, add something to your data, then:
public void notifyDataSetChanged ()
Since: API Level 1 Notifies the attached observers that the underlying
data has been changed and any View reflecting the data set should
refresh itself.