Creating a floating, editable and scrollable list in Android - android

I want to show a list of items when the user clicks an overlay item on a map. The user should be able to select any of these items and edit them. The list can have many items (more than that can fit in one active screen) therefore it needs to be scrollable.

You could do it with an activity with a transparent background, then launch that activity on top. From there you can make the list editable, by using a custom list adapter & updating the data contained within the adapter.

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.

Dynamic Listview opens a Dynamic ListView

I have a main activity which has a listview and a Fab by which user adds new things to the list view then after clicking the dynamically added listview the user can add more elements into the inner listview.
Think of an app like which has blank initial then a person adds two three countries clicks on a country then he can states/cities to it in a dynamical list view how do i achieve this.
This is a normal situation later I realized it. The first listview retrieves all the countries from the data base and you can add it to the databases too. Then touching on the listview gives set on item click listener then that particular list can be easily taken from the list. This list now contains all from that particular database.

Android: How to dynamically replace a list view with another list view like Instagram with onClick?

I'm building an android app and I'm trying to replace a list view with another list view if you click a button, like the notifications page on Instagram. On that page, if you click on the top "following" button it will show you a listview of what your followers have liked. If you click on the "you" button it will show you a listview of what people have liked your photos.
Any help would be greatly appreciated!
You can do it by following ways,
1. add Two listviews and can change the visibility as per your requirement.
2. On button click you can load the other data into same list view and can update your adapter in the same list view.
in 1 you have to load two list view at first which will consume more time if data is larger sure you can write a login in asynctask to load list views in background thread.
in 2 you have to update your adapter at the button so you will have to provide some progress bar of dialog for user while you list view is getting update.
You can use either of this whichever suites you best.
Simply , You don't need to switch Listview , you only need to switch adapters .
eg, you can switch to mFollowingAdapter when clicked on Following button and switch to mYouAdapter when you select "You" tab. that's it.
You should write a list, that has a custom adapter. This adapter will be able to display BOTH views you want to display.
If the data to be displayed is the same format (ie. both have an imageview next to a textview), you are in good shape.
When you want to switch to a different list, get the information you would like to display, replace the data in your the collection backing your list, then notify the list that the data has changed, and it should redraw.
So, this might look like:
create ArrayList() with data A
setup List, with this data and display
replace the ArrayList() with data B
call listView.notifyDataSetChanged
You can still do this if the Data A, and Data B have different views, in this case, you would need to handle this logic in your custom adapter.

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

On Android, click to expand list -and- click on a button?

I have just started my career as an android programmer, and am currently relying heavily on the sample code and api examples. I have been working with this api example, to produce an expandable list of items (note this example does not use the ExpadableListView).
In playing with the example, I tried to add another widget that would become visible and be gone at the same time as the text (mDialogue in the sample code). This works well with another TextView, but as soon as I tried to add a button widget, it stopped working. The list would expand on first click, showing my hidden TextView and Button, but it will not disappear on further clicks. The button is however, clickable, and I was able to set up an onClick listener to change the button text back and forth.
I'm starting to wonder, is it just not possible to have a clickable item inside a clickable list item? Or is there some kind of work around? Would it solve my problem if I used ExpandableListView?
You have two options of how to handle focus within a ListView controlled by ListView#setItemsCanFocus(boolean). If you want individual Views within a list item to focus so that the user can interact with them individually instead of with the list item as a whole, call it passing true. false is the default behavior.
The default behavior where ListView manages item focus and clicks is basically a shortcut/optimization for the common case where the whole item acts as a single unit from an interaction standpoint, but its layout may be complex. When you tell ListView that its items can focus it disables this special behavior and you should use the more traditional mechanisms of handling events on the Views within the list items. (Listeners, overridden on* methods, etc.)
But why do your list items stop taking clicks when your ListView isn't set up for focusable items? ListView will only generate item click events if the list item view returns false from View#hasFocusable(). This means no children of the list item can be focusable if you want to receive item click events for it. As soon as your button becomes visible, the list item has a focusable child and will no longer receive list item click events.

Categories

Resources