Google+ app listview layout with different views - android

I'm trying to implement a sliding menu just like the one found in Google's Google+ Android app:
I've got the actual sliding menu working but I'm having trouble implementing a scrolling view that can hold any type of child views.
For example I would like to have a header like the "NOTIFICATIONS" row in screenshot and below it a ListView with notification items. And I would like to have another sections below that list, perhaps called "ERRORS" and below it a different ListView with errors. And perhaps a WebView at the very bottom.
How is this best implemented?
Note: I have read this tutorial but it's talking about a single ListView. I would like to construct this using a LinearLayout or alike, if that's possible.

The way I ended up implementing this was with a ScrollView that I simply populated with Views.
There are some things to be considered when using a ScrollView, like this answer or the Android documentation.
From what I understand, if you need a whole lot of items in a list then you should look at using a ListView. Otherwise a ScrollView will do just fine.

Related

Dynamically create layout (similar to listview)

I want to create what is basically a list view but without it being a ListView.
So I have a ListView right now that pulls up a layout with a CardView, TextView, etc. However I need to create multiple lists but listviews wrap the content up and makes me scroll inside the view - I don't want this. I want to be able to see the entire list and scroll in the main view.
How can I just add the layout with the CardView, instead of displaying it as a ListView? Would be a lot easier if I could attach an adapter to a Linear Layout or something.
Edit: I know I could add it all in the XML, but it seems like it'd get very bad looking in the xml code.
ListView (and RecyclerView) do a ton of non-trivial things that are very difficult to independently implement with your own homemade alternative. Fortunately, there are many third-party solutions that address your particular problem. A good choice is CWAC's MergeAdapter. It's essentially a wrapper of sub-adapters.
To handle the section headers, you can either make the first item of each sub-adapter a header item (styled accordingly). Or use MergeAdapter's addView() method to add a "header" view before each addAdapter() call.

Android view with many different layouts

I'm creating a home screen for an Android app. The homescreen will be a vertically scrolling list, containing many different elements.
These elements can be things such as a simple card list, a side scrolling carousel of items (ViewPager?) or just a basic WebView.
Is it possible to use a RecyclerView efficiently with multiple types of content (that can also have their own adapters). Or is there something else available that I may not be aware of?
The BBC news app is similar close to what I am trying to do.
A RecyclerView is actually designed to do such things, I don't think that you have any other choices right here, however this shouldn't cause you any problems I've tried something like this earlier last month and it worked perfectly for me
even tho i added multiple types of content, the only problem that i faced was with the ListView because i added some sort of animation to the content
but after i used a recyclerView everything worked fine but you also have to reconsider using a ViewPager inside a RecyclerView as an Item, it might cause you some problems as it should be used in conjunction with Fragment to allow users to flip left and right through pages of data which in most of the cases are tabs.
checkout the documentation.
And the BBC news app that you refer to in your question is using a RecyclerView inside a tab into a TabHost that uses ViewPager.
More Information About RecyclerView.
Good Example for RecyclerView Sample for RecyclerView

Android: Layout used by wechat

In WeChat, it uses white sections for different things as you can see in below image there are three white sections in it and each item is separated by a black line:
I can suspect this is not a ListView as one might think in first glance.
Question: Does anyone know is this some built-in component that can be used or how to go about creating similar sections ?
I would say a linearlayout inside a scrollview with your custom listview and custom adapter is the most straightforward solution.
Each time the view is inflated you check the shared preference and fill in the info accordingly in your adapter. And on item click you open corresponding fragment/activity that do something. Then you issue a callback to refresh this settings view.
Might not be the most elegant way to do it. But I think this one is easy and clear.
I guess its a preferences activity/fragment but you can create it with a listview, linearlayouts or a combination of a scrollview and a linearlayout.
You have too many solutions ;)

Facebook Android App News Feed Layout

I am trying to implement a vertical listview with horizontal scroll on each item just like the facebook newsfeed. Suggested apps can be seen by scrolling to right and some part of next item is also visible.
here is the screenshot :
http://i.stack.imgur.com/7JRfM.png
So I am just stuck here and don't know how to proceed.
You're probably going to need to write some custom code (which is a pretty good rule of thumb whenever you're trying to do something Facebook did on Android; they do some crazy stuff).
I don't believe you can nest ListViews in Android. There is "ExpandableListView", which lets you expand items to show more, although this isn't quite the same thing.
I would advise to just create a vertical ListView, and have the items be horizontal LinearLayouts that you can inflate yourself. You can also try making them horizontal ScrollViews (although I think this may have the same limitation as using nested ListViews).
Good luck!

Alternative UI for Android ListView

Suppose I have a list of data to be displayed. I know how to display it using a ListView And it is very simple and easy to do it that way. But I am looking for an alternative way to achieve the same. I don't expect to have more than 20 items in the data set I am planning for.
I was thinking of a number of squares that the user can swipe to see the next one etc, similar to some widgets on home screen.
I came across android.widget.StackView, any advice available for this?
You can try StackView (http://developer.android.com/reference/android/widget/StackView.html).
This is how the Gallery and Youtube widgets are rendered.
ListView is the best option for listing lots of data. It has very efficient loading property. But if you do not want it any specific reason, you have to use ScrollView and in ScrollView, you have to place a LinearLayout and in that LinearLayout, you have to place multiple LinearLayout(for each items of data).
Maybe you can use a ViewPager (available also for lower versions of SDK through compatibility pack).
http://developer.android.com/training/implementing-navigation/lateral.html - see also the project example top right of the page : EffectiveNavigation.zip
You can use a GridView, if you want to show multiple items on a page in a different fashion than in ListView.
You can also use ViewPager (from android 3.0, or with the support library) with your custom views.

Categories

Resources