Android - Creating a List like the Grocery IQ List - android

(Using Android version 4.0.4)
I'm trying to build functionality very similar to the list found on the GroceryIQ app:
I can create a nice looking list using the ExpandableListView shown in the xml below and a custom class that extends BaseExpandableListAdapter, but I'm having trouble with the second list. Is it two lists with a view in between? Could this be just one list with a special list divider that just looks like a bar?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ExpandableListView
android:id="#+id/ExpList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#null"
android:dividerHeight="5dp"
android:groupIndicator="#null"
android:paddingBottom="60dp" />
<include
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
layout="#layout/bottom_bar_list" />
</RelativeLayout>
I've tried adding another list, but two lists on one view don't seem to cooperate too well-- either the first list is chopped off or the second list doesn't show.
Thanks for your thoughts!

So, I don't know that it's possible to know exactly how Grocery IQ crafted their list, but I found that I could replicate a pretty similar list by super-customizing the ExpandableListView.
An ExpandableListView is implemented using custom Group Items and Child Items.
I added a relative layout to the Group Item that looked like the "awesome bar". Then programmatically when I populated my list, I had a "rogue" Group Item that when I found it, I would show the "awesome bar" instead of the regular group-- in all the other cases the relative layout was set to invisible.
It took a while to get it "just right" and my solution seems a little like a hack, but that's the gist of what worked for me.

Related

can i have a listview and an expandablelistview in the same view

I have several edittexts in my view for taking input for a database query .I'm displaying the query results in a list view below the edittextfields. Because there are 7 edittextfields there is not enough space for the listview. I wanted to put all the edittexts in an expandablelistview.
Problem i'm facing is -only the expandablelistview item is shown -the listview doesnt come up at all --i have #android:id/empty and #android:id/list entries ---but nothing comes up
i can't add the listview into the expandablelistview as that is not allowed + since i need both #android:id/empty and #android:id/list to show query results i need a proper list view.
what are my options --? i could ofcourse display the results in a separate window
If you could show the xml you have right now it would be great but the ideas behind it needs to be something like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Edit:
Okay so i figured out that for this layout to function correctly you need to set dome weight so that the linearlayout understand what size to give each children. Use:
android:layout_weight="1"
in the listview and the expandablelistview (1 in both means thay will divide space between them)

How to merge several ui elements into a listview in android?

I'm making a custom view which contains an ExpandableListView, a CheckedTextView and a ListView :
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/filtersDialogView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="200dp"
android:orientation="vertical" >
<ExpandableListView
android:id="#+id/filtersListView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<CheckedTextView
android:id="#+id/onlyShowAvailableItemsCheckedTextView"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:gravity="center_vertical"
android:paddingLeft="8dip"
android:paddingRight="8dip"
android:text="#string/OnlyShowAvailableItems" />
<ListView
android:id="#+id/categoriesListView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
The problem is that the CheckTextView is fixed and the two lists are scrolling independently (which is normal for that layout). Furthermore when I expand a list item from the ExpandableListView, the CheckedTextView and the other ListView become hidden. I'd like to make a single list with all these elements that could scroll and resize properly when I expand an element of the first list (the cells of the second list are not expandable). How can I do that? Is it possible to make it without having to modify the Adapters of the lists and the controller of the CheckedTextView ?
Thanks
How can I do that? Is it possible to make it without having to modify
the Adapters of the lists and the controller of the CheckedTextView ?
I doubt that, especially as you have two scrolling views, the ExpandableListView and the ListView. I think your only option is a special adapter that will simulate the layout above. I had a custom ExpandableListView adapter that I modified into something that will simulate the layout like the one above. It's something raw so there could be some errors(I've tested it a little) and of course there are other things to work on. The code sample it's a little big so I put it here https://gist.github.com/3046887 .

TextView and ListView in a LinearLayout

I searched for similar questions but didn't get the proper answer, so posting it as a new question.
Can a LinearLayout have two TextViews and one list view? I learn that listview can be used to display array elements only if the class extends ListActivity. The Class in my app extends Activity and uses listView.
I am trying to build an RSS Reader based on IBM tutorial. On running the project I am getting parsed text in both the Text views but ListView is not displaying. I can post the code and Logcat if required.
Linear Layout can have any number of children.
ListActivity is an Activity that Android have added for convenience when dealing with activities comprised of list.
You can use ListView on a regular Activity and just implement an adapter that will populate the list items with data from your model.
Android has some ready-made adapters that can be used for simple use-cases.
of course if you need a more complicated beahviour you can extend them.
Have a look on BaseAdapter, ArrayAdapter and CursorAdapter to get a better understanding of how to use adapters.
You can have a ListView in any activity, using a ListActivity just makes your life easier (usually). See here for details.
You can have a Linear layout with different views and list view inside for example:
?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/background_new_search_activity_1">
<TextView
android:id="#+id/list_item_amount_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000"/>
</LinearLayout>
And yes you can use the ListViewin all the activities, it is not necessary to extend ListActivity
Make sure the orientation of the ListView is set to vertical. Otherwise, it will try to display all items side by side, and those that fall outside the available view area won't be visible.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"> <!-- << orientation setting here -->

list inside scrollview

On my screen I have a list view and a button. my list has like 8 item. I would like my screen to scroll if both these items does not fit in. I don't want my list to have scroll but the complete layout including both list & button. If I use the below layout it only shows on item inside the list and I have to scroll within the list to go to next item.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" >
<LinearLayout
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="#android:id/list"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:background="#drawable/round_background" />
<Button android:text="Search" android:id="#+id/carSearchButton"
android:layout_gravity="center_horizontal" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
You can't put a ListView inside a ScrollView. Of GridView, or whatever View that handles scrolling on the same axis as the ScrollView does. That way the framework wouldn't know which View should handle the scrolling event. This layout won't produce an error when you compile it, but it won't work properly.
What you should do here: dump the outer ScrollView, you don't need it. Only use a ListView, and add the button to the ListView, using .addFooter(), that's the easiest way. This way your button'll appear as a list element, but you don't have to mess around with a custom adapter.
Scythe kind of answers my question but I wanted more then one one control below the list also on another screen I wanted 2 lists. So in order to have the scroll bar working with list view I had to fix the height of the list.

Sectioned ListView and ExpandableListView

I need to create a layout with a title bar on the top and a list view with n sections. The
list header of every section has got two distinct Buttons that must be clickable and focusable independently from each other. This is the code of the layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/title_bar" />
<ListView android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
/>
</LinearLayout>
I tried this two solutions but I've found issues that I am not able to solve in both:
1) Using a sectioned adapter (source code can be found here). It works fine without the title bar but with the title bar the default focus algorithm doesn't work any more.
2) Using an ExpandableListAdapter (in this case obviously the ListView in the layout becomes an ExpandableListView). It works fine but if I press the dpad center button on group layout both buttons are clicked. I did not find a way to solve this.
Anyone can help?
Thanks very much!
How about trying Merge adapter https://github.com/commonsguy/cwac-merge it allows you to add multiple list and buttons !!

Categories

Resources