two listviews in fragment? - android

I'm new to android development, and I have doubts about working with fragments.
I have to build an App that runs 2 ListViews on the same screen, but the list on the right depends on what I select in the list on the left. I've looked through all the tutorials and samples about the working with Fragments, and I haven't found a way to do that succesfully.

Hey refer this link and follow the example explained there. In the example given you have listfragment and when clicked on an Item, details will be changed. So You implement another listfragment which will display items upon selection of first listview instead of Details.

Related

How to create history of all pdf file clicked by user?

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?!

Add a single fragment to a screen multiple times

I am new to android and I am working on a project that displays cards (like on Google Now but all cards are the same size). My question is, is it possible to add the same fragment (a general design for the card) multiple times to the same screen and have them be position after each other in a row or column? If so how would I go about that?
Yes you can. Create a template fragment (eg. TempFragment extends Fragment). Then initilise a new TempFragment each time you need with the data you want to display and use a FragmentManager to add it to the view you want. As for the row or column layout you can use TableLayout in your main layout. Your question is very vague and I'm afraid I can only help you this far.
You can use your Adapter's item to implement your fragment. Google's Api Demos has this kinds of example( Support4Demo).
You can use RecyclerView with its Adapter class. Google uses same subject for displaying a similar layout items.
https://www.androidhive.info/2016/01/android-working-with-recycler-view/
you can see here ... there is all you need.

Listview navigation in Android

I have a custom Listview in my android app and on list item click, I'm able to navigate to other activity, which shows all the details about list item !! Now my question is, I want to navigate to next/previous listitem's details through second activity.. how can i do this.??
I'm new to android and stackoverflow as well..
Thanks in advance !
I guess this is more of a design question, so i'll answer that way -
Your best bet will be to use something like a ViewPager in the new activity, which receives the selected item position and displays it with underlying adapter having the same items from the previous activity. using the ViewPager the user can swipe left and right between items.
For a good example on this usage, you might want to take a look at "Google Reader" on Play Store which has this exact same design pattern.

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 :-)

Showing detail from a ListView

What is the correct way of showing a new View with more detailed information from a ListView in Android? It's a topic that I can't find a solid answer for in either of these Android books.
For example a list of contact names, one is selected and a view shows their full details.
Do I launch a new activity for this or use a ViewFlipper?
Your approach is right. It's the recommended one.
When designing an activity, it's suggested to use this paradigm:
One activity = one thing to do.
Viewing the list
Viewing the details
On the Notepad tutorial app, a new activity is launched to view the details of a list item.
Anyway, the ViewFlipper is another possible approach that keeps all the content in a single activity. This approach is suitable if you manage the Back key correctly.

Categories

Resources