How to add a ListView inside a ListView - android

I already have a ListView where each row contains two TextViews and a ImageView. But what I want to do now is to add number of ImageViews into my row. How can i do it? is it by using Nested listviews how to do it? and can i use the same id android:id="#android:id/list"

You should either go for ExpandableListView, and add the
TextViews to your parentView renderers, or
You can create your
own renderer for the list, where each item is a View containing the
two TextViews and a ListView.
Your inner ListViews can have any id attribute, since it does not need to be unique, and from the Adapter implementation you will always know exactly where you are (in the tree).
A sample implementation of a nested view can be found here.

Related

Sum up a group of dynamic objects

I'm currently a bit overstrained how to realize the following problem.
I want to realize a product overview as the figure shows.
In C# I would add a panel and add objects of one product (checkbox, textview, imageview) with a fixed position specification. And just group it for the others.
But how can I realize this (optimal) under Android Studio?
You can use a ListView with custom row layouts.
Your custom row layout can be a RelativeLayout, containing a CheckBox, some TextViews and an ImageView. It will be reused for every row by the ListView adapter. If you need the checkbox to indicate which rows the user selected (common in Windows UIs), consider implementing Checkable list views.

Multiple HeaderView for ListView

I wanted to know that is there any way to have multiple HeaderViews for a ListView or on the other hand i want to implement a ListView with three static rows at top and other rows with an adapter which will loaded from AsyncTask,according to ListView recycling i can't make three first row static by using position in getView() function of my adapter body. is there any suggestion to this issue?
If your data is static and always visible, then just put it outside of your listview, above it. And you should have the effect you need.
I used this Library it was useful for implementing Multiple Header ListView, if the first three rows are static then you can add them statically first above the ListView then set the adapter for the ListView and in this case you don't need to use the library
Wrap three views inside a layout (For example a vertical LinearLayout), and add that layout as the list header.

How to list Views (or Widgets) in one scrollable screen

I have the following prototype:
What is the way to list views in a scroll-able way in a screen?
What I have already tried:
I tried to create a class and extends the LinearLayout class and dynamically adds my Views (the compound controls class is my view also extends LinearLayout) to the main LinearLayout. So I got a list of my views which is scroll-able.
I'm not sure what you mean, but looking at what you have tried, what's wrong with using a ListView? As the name implies, it should do exactly what you want:
What is the way to list views in a scroll-able way in a screen?
Here is a quote from the android documentation of a ListView
ListView is a view group that displays a list of scrollable items. The
list items are automatically inserted to the list using an Adapter
that pulls content from a source such as an array or database query
and converts each item result into a view that's placed into the list.
You should be able to add a ListView directly as a sub-view under your LinearLayout.
your questions seems like hard to understand.
did you mean how to set the whole page(activity) into a listview?
listviews are scrollable in default (of course, you can see it if the list is long enough and you can set the whole activity as a list).. you can customize it also by using templates (xml)
and extending ArrayAdapter of your type (let's say ArrayAdapter<UpcomingEvents>) and supply data from db...
is this what you mean?

android: Is it possible to put multiple layouts in listview items

hi I want to use a listview (probably) is it possible to fill each entry with say two buttons two text areas, and have them laid out with realtive or linear layouts?
I have used a scroll view with layout inflator to achieve this at the moment, but I'm thinking listview would be better maybe?
yes you can. you need to use a custom list view for that. making an activity by adding a listview in it and then referencing another xml to that listview using an AAdapter so that every element of the listview has the layout of the second xml file. this tutorial should help you understand the idea.
Yes you can place any widgets for the particular List Item for your listview.
For defining that kind of ListView, you have to define a custom adapter, follow the below steps:
Define a one row file for the list item, say for example, RelativeLayout with 2-3 TextViews.
Define a class by extending BaseAdapter.
Inflate the XML and do display operations inside the getView() method of this class.
Set this adapter to the ListView.

Placing multiple objects inside a list view

We are developing an Android project. In that project we need to create a list view with multiple objects.
Inside each list view item we need to show Name, Mobile, Checkbox1 and Checkbox2
We tried with various options and we are clue less how to get this done.
You can create an .xml file, which contains a Layout (LinearLayout, RelativeLayout etc) and inside that layout put some Views like TextViews for the Name and Mobile and 2 CheckBox items for your checkboxes. I recommend this tutorial for more on ListView issues.
You need to define your own row layout and also your own ListAdapter implementation. The adapter needs to override getView to return your custom row view. There's a good example here that extends an ArrayAdapter. There's another example here that extends a CursorAdapter. Search the web for android custom listview row to get lots of other examples.

Categories

Resources