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)
Related
This is what I want for my app
I am stuck at passing my recycler view to the recent tab or you can say history tab...
I have created the pdf app in android studio everything is working fine but the problem that i m facing is i dont know how to add the same recycler view item from one tab(docs tab) to other tab(history) whenever i click on my pdf file.
I want to replace the file in history tab if already present in history list and add it to the 0 position of the history tab.
You have two options:
1- To basically just always show one recyclerView but update the items sorting whenever the top buttons are clicked.
2- To load 2 fragments for each tab which both have the same items but different sorting.
None of them are really hard especially 2. Just do a basic tab layout (lots of tutorials for it on YouTube) and in each fragment just use a different sorting function. For doing 1, you should use DiffUtils to update your list beautifully and fast.
Although I am not sure which part you are having a hard time with. Doing two tabs, updating the recyclerView, or remembering which files were opened last?!
Thanks for all the help recently! Another question!
In the app I'm building, I currently have a layout file with an expandable lstview where you can choose 10 options. When you choose one of those options, you pick another 4 options. From picking the week, you then have 3 more options. Each of those 3 options will currently open a new activity that has a listview with a checkbox and textview in each row, with about 10 rows each.
Instead of making 30 layout files which will probably crash the app(not sure how many it would take to crash the app), I'm thinking there has to be a better way. I have looked it up and can't really find what I'm looking for. I have read a little bit about sqlite, but wouldn't you still need separate layout files to call different parts of the tables? Is there a way to make a single layout file with a list view, and fill the listview with different data from sqlite, depending on where the click came from in the expandable list view?
For example, if they click workout 29 on expandable list view, then click Week 1, then click Day 1.. can that single layout load data from sqlite db. Then if they were to go back and say click workout 30, week 2, day 3, that same layout load different info from the db?
I'm also trying to find out how to make a double expandable list view still
Thanks again!
So this is very simple all you have to do is create a DataAdapter for the listview. You can then add list view items which bind to the onclick listener and then you can clear that list and add new elements to it. a useful link would be.
https://guides.codepath.com/android/Using-an-ArrayAdapter-with-ListView
You should be using a SQLite database for all your data (unless you plan on holding the data in memory which is not a good idea if it is a rather large amount). You should just create a simple view and keep reusing it. What you will have to do is create your own adapter (extending from BaseExpandableListAdapter for Expandable list views and BaseAdapter for normal list views) and then query the SQLite databse table for the data that you need.
If you are only displaying String items, you can directly extend ArrayAdapter and then provide the array of items that you want to display for the normal list.
As far as crashing goes, there are many apps that have well over 30 layout files. Besides even if you did start loading a lot of views, Android will automatically start destroying views as it starts running low on memory and recreate them when it is needed to do so.
I am trying to create a fragment and inside that i want to create multiple textviews whoose text is set from the data retreived from the database(mysql).
And also i want to have the feature "refresh" by which the textviews are updated with recent data from the database.Iam trying to do that but iam not getting enough idea how to do it as iam new to android programming.
Please help me with this. thank you in advance and any suggestions are acceptable.
i.e
I have database of a person and i want to get his name and address from that,then in my activity i want to create a fragment that displays a name and address in separate textboxes and if address or name exceeds some length then i can press "more" to see left information
Consider using a ListView to populate data from the database, and a SwiperRefreshLayout to refresh it. Check these links for more info :
SwipeRefreshLayout
ListViews
The answer depends on what your app will do.
If you have a fixed number of TextViews, and the number won't change in the future or depending on the answer to the database query, you could simply stick to normal TextViews; if the number changes, I suggest using ListViews or ExpandableListViews.
Regarding the layout, you can create a normal layout using AndroidStudio's layout designer, and then inflate it to your view.
For the refresh, you can add a button that calls the method in which you fill the textviews/listviews.
Actually your question is too broad: if you want a more specific answer, you should edit it asking what you really need.
My application for android tablet contains 3 parts in one single view.
Listview items
On Click of list that contained in first part the second list items is shown in second part.
On Click of list that contained in second part the detils of each list should be shown in third part.
How to achieve this?Can Any anyone help me with some examples.
add one ListView and two fragments into Activity . Both Fragments will have their own Life Cycle .
I've create an application using JSON. It shows the list of some items from one link whatever i used in Codes. In my application i've using 2 layouts for display the items. First layout doesn't have any problem. But, when i go to next layout the result of first layout also show here and overrides the second layout's contents. I'm using android:list for list that. Can anyone clarify this doubt? Thanks in Advance.
Make sure your ID on your Lists are different. This could cause the problem.