Rendering complex ListView in android - android

I am developing an android app similar to other social network app such as Facebook , Google plus. Similarly my newsfeed ListView have multiple views type and also complex. Even though i am using ViewBinder , my list view feel laggy as i add in more view types. There is a clever alternative solution here. They split each list item into multiple components such as header , content , footer and so. I planned to adapt and find it difficult to start code on my own. Is there any working code available out there similar to this technique?

Consider using a RecyclerView. It's a little more work than using a ListView but it should handle the complexity you're looking for.
http://developer.android.com/training/material/lists-cards.html

Related

What are the alternatives to RecyclerView for a feed

An app includes a feed like Twitter or Instagram.
Tried it with the RecyclerView.
Would Litho (fblitho.com) be a good alternative to make a good feed with text, videos and pictures? Or maby other libraries?
I would suggest learning more about RecyclerView before trying to move onto different libraries. Even if you do end up using another library, it's always good to have a better understanding of what it's being built on top of.
RecyclerView is the best way to handle feeds like you're looking to build. Even with images, or videos.
If you have any specific questions about RecyclerView, you should ask them here. For example, why does RecyclerView not fit your current needs?
I strongly recommend you to take a look at epoxy. As it description says, it is an Android library for building complex screens in a RecyclerView. Models are automatically generated from custom views or databinding layouts via annotation processing.
Wish it can help you.

Intuition behind View and adapters

What is the intuition behind views and adapters in Android, that means from where did the person who made this concept get the thought process necessary to create these elements? To elaborate, the concept of circle originated from nature, moon sun such celestial bodies, like wise what is the intuition behind using listview and adapters?
As you probably already know, using ListView (and more recently, RecyclerView) on Android requires the use of an Adapter to get the data from the data source and turn it into something displayable which can then then be shown in the list.
So why did the engineers at Google implement ListView and the backing Adapters the way they did ?
It essentially comes to a few things:
Performance:
Imagine you have 1000 contacts, each with a picture and various pieces of information. You want it to work well, load quickly, and scroll smoothly. The naive way of doing this might be to create a scrollable layout to hold the contacts list, and then simply add a sub-layout for each contact. Unfortunately, this will fail all three requirements: It won't work well, as there won't be enough memory (ram) for all those contacts and especially the associated pictures, and the app will run out of memory and crash; It won't load quickly, as all the contacts and the contact pictures have to be loaded into memory before the list can be shown, which will take a long time; And it won't scroll smoothly because you don't have all of the advanced caching, pre-rendering, and bitmap texture caching that ListView and the adapter does. Use a ListView and an Adapter, and it solves all these problems for you.
Adaptability and ease of use for developers: ListView and Adapters are used for lots of different things, from contacts lists all the way to to complex pages with different answers, comments, and tons of other information in the Stack Exchange Android app. Adapters make working with data from different sources easy: there's a single, common API, which can be used and extended to display any kind of data, much more easily than if every developer had to implement their own solution. Want to load more data when the user has scrolled to the bottom of your list ? Sure, it's easy. Want to have different kinds of items in your list ? Sure, It's really easy.
So, did Google and the Android developers and engineers invent this idea of using adapters ? No.
In fact almost every system or environment which involves showing a list of items uses something similar: The actual list of items, an Adapter behind it, to transform the data and make it displayable, and then the actual data source, which can be anything which gives a list of items, from a database to a web service. It's essentially this: data source > adapter > list where it's displayed. This kind of pattern is used in desktop Windows applications, on iOS, web applications, so the Google engineers took this concept and adapted it to Android.
That's why ListView and Adapters work (and are used) the way they do.
PS: here's a Google IO video by the Google engineers on how to use ListView and Adapters correctly, and a little bit on how they work under the hood: http://youtube.com/watch?v=wDBM6wVEO70.

How To Make List Of Fragments In Android Programmatically?

I'm working on an Android application and one of the features is a list of upcoming events. I need to be able to generate a 'card' so to speak for each of these events and place them in to a scroll view. This would be simple if I knew how many there were going to be and could prepopulate an axml file but I must populate the scrollview programmatically based off the parse of an xml file on the web so that the client can keep it updated. I've searched everything I can think and the best I can find is a custom list view which I do not think will provide the results needed. I've uploaded an example of what I'm trying to do to my google drive and linked to it below. I should also mention my background is completely C# and I've only been working with java for the last two weeks or so, so if anyone could provide a working code example I would be most appreciative.
https://drive.google.com/file/d/0B8alYNlu3SuoSEk0bE55cDhXWVE/view?usp=sharing
I think that basically what you need to do is to implement a RecyclerView using a LinearLayoutManager (this would represent basically a list) with CardViews as the items or just regular layouts designed by you, the CardView will just make your life easier if you need the Material Design cards appearance.
You have many different tutorials as how to implement this, as you can see here:
http://www.binpress.com/tutorial/android-l-recyclerview-and-cardview-tutorial/156
You'll see there that it's exactly what you need but with smaller Cards.
Let me know if this helps.

How to Create Timeline UI on Android

I want to create android application that read RSS feed from some websites. My application should be like this picture below. I don't know how to create timeline UI like this. Should i use webView to create IU like this, or there's any other approach ?
Take a look at Card UI, this could get your job done.
https://developer.android.com/training/material/lists-cards.html
There is no significance of using a webView for a timeline layout. You would (almost) definitely be using a listView or (even better) recyclerView.
Additionally, to comply with new material design guidelines, you can use cardView. see Creating lists and cards.
These are basic design elements. You should at least be familiar with listView implementations if you intend to create such a UI. Here is a nice tutorial about using a listView.
Vogella - Using lists in Android

Android Custom GridView with Masonry Logic

I'm quite new to the world of Android development, and I'm relatively comfortable working with Adapters and GridViews. However, I'm looking to build something a little more advanced with GridViews that seems to be proving quite difficult without using third-party libraries (impossible from what I've read). Even using a third-party library like Etsy StaggeredGridView (https://github.com/etsy/AndroidStaggeredGrid) I can't seem to get it right. The best I can get is having rows that bleed into other rows, Pinterest-style, but what I'd like is something along these lines:
Where every nth cell actually has the width of two cells and offsets the grid.
So what I'd like some direction on is:
How could I accomplish this repeating pattern using a GridView/ Adapter combo?
Or failing that, how could I do this more efficiently than nesting a bunch of LinearLayouts inside a ScrollView and doing some really messy logic?
You can't. GridView has no way of merging columns like that. You can try using a GridLayout or TabletLayout to obtain that look. However neither support an adapter. You're best bet is to look for 3rd party libraries.
If there isn't going to be a lot of scrollable content, I'd go with (Grid/Table)Layout. You may take a small hit with memory consumption but you'll save yourself a lot of time in implementing your own custom solution. Which just may be your only choice if no 3rd party library exists.
One possibility would be to looking into RecycleView. It's a new view coming out with Android L that will also be in the support library. It's basically a more advanced version of a ListView that allows you to build customizable layouts that scroll and recycle their content. From the looks of it, it appears it would allow you to build an easy solution for your case.

Categories

Resources