Android Studio Dinamically add a new Section - android

I'm a beginner in Android development and I'm stucked in a way to dinamically add or remove a new Section.
The image below shows the way I want to do it. If I press the + button then a new item is created and I can insert the info about the item. If i press the - button then it will delete the item.
I don't want to make the items to be fixed. I need the user to insert as many items as they want to.

For dynamic views I suggest RecyclerView, which is more flexible than ListView and provide basic animations by default (proper calls on adapter - notifyItemInserted, notifyItemRemoved).
Here is an example.

Related

Creat a listview when I click a button in android

Hello guys I am new on android programming.I want to create a shopping list app so the idea is first. This is my idea :
There is no list then when I click the Add Button
I can give a name to the list and after that add it ( where I can fill this list with products to buy later )
The problem I have is:
I can't find an idea how to create a list when I click a button like this image :
How can I create more than one list and show them like the picture below.
I don't need code, I just the idea and I will search for the rest myself. I already look everywhere but couldn't find solution for it. Thank you guys.
You don't really have to createp a list if you click the button. You have to create the list in the UI or the xml files. If you click the add button, what you want to happen is to add data for the list to display. If you don't know about ListViews and how to add data to them using adapters, I suggest reading more on the topic:http://www.vogella.com/tutorials/AndroidListView/article.html

Access Adapter items of Recyclerview

I'm using Recyclerview to show a list. I want to delete some items like IOS. In my listview template I have added a button to delete item which is invisible by default. In my activity I have another button attached at bottom (Not part of listview) and on tap of this button I want to make all delete buttons of listview visible.
My Question is how can I get reference to all delete buttons of listview in activity and is it the right way to do this?
Thanks
Assuming you have ViewHolders set up, you already have references to all the buttons in your list. All you have to do is to make them visible for every item in the list with a simple loop.
In case you haven't implemented ViewHolders I suggest you check out the documentation and take a look at some simple tutorials on how to use them.
On a side note. If I understood correctly you're making a bottom tab for your app and since you referenced iOS I gotta say this; Remember that Android and iOS are two unique operating systems with their own ways of handling things. Check out Googles pure Android documentation.
In your question title you say RecyclerView, but in your text you say ListView. The solution is similar either way, but it's best to be perfectly clear what you're doing.
In either case, there are at least two different solutions.
First, you could use a boolean flag to determine if all the the item buttons should be showing or not. You check this flag at the time the item view is inflated or created and toggle the button accordingly. If the boolean flag is ever changed, the easiest thing to do is tell the RecyclerView/ListView that the underlying data has changed and to redraw all the views. Call notifyDatasetChanged on the adapter.
The other thing you can do at the time the item buttons should change is iterate all the visible item views, find the button, and change its visibility. With RecyclerView, you can do this, and with ListView you can do this.

how can i add and remove elements of a listView?

Hi guys im making my first android app, it has 4 fragments, inside one of those fragmentes a listView is gonna be displayed, and i need to give the option of adding and removing every element of the listView to the user (every element of the list view is supposed to link to a unique fragment that has some information regarding to it) , so where should i save the elements of the listView?
thanks very much.
im using java (android studio)

Android dynamic rearranging layout

I need to create a UI that allows the user to rearrange its elements and store the configuration of that arrangement somewhere. And when the user opens the application the UI would load as the user arranged it.
Just like you would rearrange the icons and widgets on the homescreen. Is there a tutorial for that? What approach would you suggest?
Thanks
This question is farly near rearranging items on a ListView. You should check this question:
reordering of listview items by drag and drop using android

Android ListView that opens a subset

I would like to design an item like this that opens a subset of other items when clicked, I have only seen it in other applications I've used, and I can't find any resources on how to create it. Does anyone know how to?
Thanks.
Its not clear if you want to created Nested listviews that look like this
-Item1
-Item2
---Item2A
---Item2B
-Item3
or if you want to open a completely new list when the user clicks on an item.
If you want to use a nested listview look at this question: android nested listview
And if you want to open a new activity, then create a 2nd activity with a listview and open that on an item click
Perhaps you should try to have a look at the ExpandableListView.
Documentation is available from here:
http://developer.android.com/reference/android/widget/ExpandableListView.html
If you wanted to add a ListView that opens another list, you can do it in several ways. I've successfully done it by adding an OnItemClickListener to the ListView and then simply load a new set of data in the ListView and update it using invalidate() or by setting a new Adapter.
You could even add some cool transitions or animations, and create a listener for when the animation is completed. Lots of cool ideas :-)

Categories

Resources