Best way to create ListView for Android - android

I am beginner. I am looking for Tutorials of Swipe / Refresh / Listview with adapter which Data comes from Parser.com. I can't find in the web the suitable one!
I tried a lot of one but nothing work well.
Can you advice where can I get one is working well and easy to understand?
I work with Fragments, I don't know if it is correct way to work with theses fragment to create ListView?
Your help will be appreciated!
Regards,
Marwan

I'm typing here because I can't comment.
I learned how to use list view from
https://www.youtube.com/watch?v=BSZLqBWKTHw
and
http://developer.android.com/guide/topics/ui/layout/listview.html
As for using fragments, You can put them in fragments. I would do that if the fragment would be used in more than one activity or if you want make use of space in larger screens.

Related

How to create multilevel recyclerview in Android kotlin?

I want to create 3 level RecyclerView like tree view in kotlin. Is there any tutorial and suggestions please let me know.
I already tried so many times with ExpandableListView and 3 RecyclerView, but didn't find any proper solution.
By a multi-level RecyclerView, do you mean a RecyclerView with paths to different lists that branch depending upon which item has been selected? If that's the case, I would honestly recommend using a single adapter to cycle through multiple lists depending upon user input.
If you have a root list containing two items, each of which opens up its own list with its own unique set of data, you can easily implement code that notifies the adapter of which item in the root list was selected. From there, the adapter can update and switch the view accordingly. This can be applied to series of lists ad nauseam if you so choose, though I can't say I would recommend this kind of method for incredibly complex webs of lists that interact with each other.
Like Ircover said in their comment, I don't think a tree is necessary in this situation either, if only because (1) as stated, it isn't really best practice to do so for the kind of application you're making, and (2) it may unnecessarily over-complicate whatever you're trying to achieve with these branching paths in the first place. If you're willing/able to provide more information about what you're trying to do here, that may help others help you more precisely than I can :)
Full disclosure here: the blog post linked above is not a direct match that will solve your problem - it pertains specifically to displaying different types of data sets (from data classes and what have you,) but employs code that shows how different sets of data can be switched between in a single RecyclerView. Even if it isn't a god-sent solution or is only halfway helpful in solving your problem, I think it can provide some useful information to you.
Maybe a slightly dated question but looking into the same concept and I located this page https://blog.usejournal.com/multi-level-expandable-recycler-view-e75cf1f4ac4b .
They have made a single adapter class to take care of all the navigation and so far seems to be the least complicated example of an expandable RecyclerView, though not in kotlin.

Two Custom ListViews inside an activity for larger displays

Android 2.3.3
I have an activity where I display "Device's Contacts" in my custom view(imageview, 3 textboxes, checkbox) inside a ListView. What I want to do is, display two listviews with both showing alternate contacts (Splitting the listview into two) side by side. This is because, I want to utilize space on landscape mode of larger displays.
I haven't seen many questions on SO and somewhere I have read that, this approach will mess up scrolling of listviews and will get messy.
So, can someone explain why/how would it get messy and is there another way to use the space in larger displays in my scenario.
Thanks.
This sounds like exactly what the Building a Dynamic UI with Fragments android tutorial was designed to address.
As #ooops mentions you will need to put each ListView within its own container. In the tutorial I linked to, they accomplished this by using 2 Fragment instances, each that loaded different content. Whether you copy their example and use the <fragment> tab (admitidly I don't remember which API level that works on) or use a different container like a regular LinearLayout you should be able to acomplish this easily.
You could do this, but each ListView should be in it's own container.
For examlple How to use multiple listviews in a single activity on android?
But be aware that #Rarw is more correct in the way of good programming practice. Fragments are recommended for such purpose.

How to Use Adapter While Filling Layouts

I know it may be weird that I want to succeed.
Let me explain whole in details. Firstly, I want to use two ListView looking in an Activity screen. Just like how Pinterest looks like. (I'm not sure is it true but it's named as heterogeneous gridview.) There is also one thing that I needed to implement: lazy loading. There are about 30 images in my activity, so that's not good to fetch all images at one time. That's why I needed lazy load.
So in first, I pondered on that I how obtain that appearance, I mean heterogeneous gridview. Then decided to add to LinearLayout in a ScrollView. Linears have vertical orientation. With thay approach, I added my new views by using odd-even method in Linear Layouts.
Althought, there weren't any adapter so according to my knowledge, there is no way to controll which items would be displayed. So lazy load is not suitable.
I've also tried two ListView in an Activity, but got some lag and also synchronous scroll problems. On the other hand it has a bad recycling.
So in this scenario, I want to ask is there way to fill LinearLayouts using Adapter? Or what would you recommend to create a heterogeneous gridview but also with lazy load.
If my approaches are wrong, I would not hasitate to change it.
Any clue would be great for me. If there is something unclear, please specify it. I'll explain with more details.
After a lot of research, finally I found a library which have lazy loading and heterogeneous gridview and also not has any scroll or recycling lags/problems.
Maurycy's StaggeredGridView is completely what I'm looking for.
Here is the library and also there is a demo too.
If I get your question right, here is what you need: http://spinlist.autsia.com/

HorizontalPager

Hi i've just implemented a horizontal scroll for my android application,according to some excellent sample code that i received from here my only problem is that I'm swipping through TextViews what I actually wanna do is swipe through activities.As you will see through the link i provided the TextViews are defined in the .xml file from the horizontalpager so scrolling through them is done quite automatically.How can i achieve the same results but this time with activities?
Activities arent Views so no way and no good idea anyway!
But what you wanna do can be done with a ViewPager and Fragments!
Fragments:
http://developer.android.com/guide/components/fragments.html
ViewPager:
http://developer.android.com/reference/android/support/v4/view/ViewPager.html
Edit: Here would be the Adapter you would wanna use:
http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html
Hi i came accross to an excellent blog explaining very explicitly the above and also providing some sample code so i'll post it just in case any one stumbles upon the same problem as me, note: that's a link for quick downloading of the sample

Whats the best way to display information in Android

I am currently making an android application which need to present a lot of information from different arrays. On each horizontal line there's gonna be four different texts and then I need to be able to scroll through all information displayed. I know ListView is one way to go, problem is I dont know how to use four text views horizontally in a ListView. Any tips or help to get the best way to present the information would be grealy appreciated.
Basically like this:
You have to extend ArrayAdapter and override getView() of Array Adapter.

Categories

Resources