Is it possible to have a custom expandable list view in android with scrollview?
ListView already have scrollView associated with it, you can use MergeAdapter to achieve this
I don't think any of you got his question right! He is asking about the "expandable" list view. Anyways I also seem to be having the same doubt.
I still think the answer is NO.
You may be able to use custom views and them inflate them into an already existent layout element which will give you the same effect. And I think that solution will be better.
ExpandableListView has its own listview. You don't have to integrate another listview on it. Notice that if you have a long list, vertical scroll is associated automatically.
combination of listview withing scrollview is not happening to be good option. if you will place any listview within scroll view the listview will not scroll. Its seeming to be officialy said by google android programmer that this will be a bad user experience.
Of course, combination of expandable listview withing VERTICAL scrollview is not happening to be good option, but using it within HorizontalScrollView works impressive. I use this method in my program. User can horizontally scroll long strings.
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
android:id="#+id/RelativeView01"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:id="#+id/btnSaveSelection"
android:layout_alignParentLeft="true"
android:layout_width="100dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:text="#string/SaveSelection"
android:focusable="true"
android:background="#drawable/android_button"
android:onClick="myClickHandler14" />
.........
<HorizontalScrollView
android:id="#+id/HorizontalScrollView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:scrollbars="horizontal|vertical"
android:layout_above="#id/button_add_group"
android:layout_alignParentTop="true">
<LinearLayout android:id="#+id/LinearLayout02"
android:layout_width="wrap_content"
android:orientation="vertical"
android:layout_height="wrap_content">
<ExpandableListView android:id="#+id/android:list"
android:layout_width="750px"
android:layout_height="wrap_content"
android:groupIndicator="#android:color/transparent" />
<TextView android:id="#+id/android:empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:text="#string/no_data"/>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
Related
i have seen a lot of android apps those have a ListView that some differences with my ListViews. in theire ListView Scroll bar seen like this:
in picture above when you scroll your list that scroll bar will be shown and u can touch on it and scroll easier.
but in my app seen like this:
this is my layout xml code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="4dp"
android:text="#string/do"
android:textSize="16dp" />
<ListView
android:id="#+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_background"
>
</ListView>
</LinearLayout>
i had googled many times but i didnt find any trick. can anybody help me how i can make my scroll like picture one?
You can add these lines in your listview. It worked for me.
android:fastScrollEnabled="true"
android:scrollbars="none
set android:fastScrollEnabled="true" in properties of the listview.
Also if you want fast scroll thumb to be visible always, set android:fastScrollAlwaysVisible="true"
then, in your xml definition of the listview, you would have something like this:
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fastScrollAlwaysVisible="true"
android:fastScrollEnabled="true" >
</ListView>
Hi Use This attribute in your ListView which you declare in you layout file.
android:scrollbars="none"
Im trying to manipulate the to do the following but its so far just lead to frustration... following is the poorly draw picture of what I am trying to accomplish:
http://i.stack.imgur.com/WZOta.png
http://i.stack.imgur.com/6cEQk.png
<?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:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<ListView
android:id="#+id/android:list"
android:layout_width="wrap_content"
android:layout_height="419dp" >
</ListView>
<TextView
android:id="#+id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/FAP001"
/>
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="+1" />
</LinearLayout>
</ScrollView>
Im not sure if the listview is the way to go.. heck im not even sure if linearlayout is a good call.. Im trying to have end result close to what is on the 2nd image.
THANKS IN ADVANCE!!!
You can't place an ListView within a ScrollView. Thats not possible. Because then the ListView has got two options to scroll trough the content, as you will. And this won't work.
For more Information:
https://groups.google.com/forum/m/?fromgroups#!topic/android-beginners/LRpLgGOy2Pc
If you want to have a ListView with 3 "sections" I would recommend you to create your own custom ListView with a Custom Adapter.
Here is a an Example of an custom ListView
http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/
You can just take this ListView and just have to modify the Adapter and the Row XML to your own needs.
I'm trying to mimic the behaviour of the HTC SMS application (tradional view), where all messages are shown, and an EditTextis shown below. As you can see in the screenshot, when scrolling upwards, the EditText scrolls away at the bottom.
I'm stuck with this, even after reading multiple posts (eg Android Layout with ListView and Buttons and this website: http://www.finalconcept.com.au/article/view/android-keeping-buttons-visible), it's not working as expected.
Thanks to the comments and EditText now showing under ListView, I've managed to have my ListView take all available space and start scrolling once completed. The EditText is showing at the bottom of the screen now - always. I'd like it to disappear at the bottom when I scroll up though - now it remains at the bottom
Current Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:id="#android:id/android:list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<TableLayout
android:layout_weight="0"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<EditText android:id="#+id/newmessagecontent"
android:layout_height="150dp"
android:singleLine="false"
android:gravity="top"
android:layout_width="250dp"
android:layout_alignParentTop="true"
/>
<Button android:layout_height="wrap_content"
android:id="#+id/sendmessage"
android:text="Send"
android:layout_width="wrap_content"
/>
</TableRow>
</TableLayout>
</LinearLayout>
i think what you need to implement here is some sort of modification of the SeparatedListAdapter from Jeff Sharkey from this Article. In this article he not only manages to add two Adapters to a ListView but also explains how to have Headers to separate them if you want (you can remove that part of the code).
So what i mean, is your first Adapter will be the data with It's rows, and the second Adapter will be a dummy one with no data that just points to a View with your controls or whatever.
this way the ListView and what you want to add at the bottom are gonna be all scrollable.
Hope this helps.
A ListView automatically scrolls if all the items in it take up more space than the view provides. What happens if you remove the ScrollView?
I am having an issue that make me crazy
I have a listview with WebView inside. So I created a custom listview.
The WebView forbid me to click so I created a webviewclicklistener.
My problem was that when I display some images, my webviews are "shaking" as if it wants to load the image a thousand times.
In fact I discovered that the height size of some elements change like every seconds, that give a feeling of shake.
The only way I found to fix it is to give a layout:height value for my listview.
My new problem is that when I put for exemple 600dip, I have a scrollbar, but I can't look at the end of my listviews.
If I put like 1000dip, I don't have scroll bar and I can't see the end of my list neither.
Here is my layout
<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/woodbackground"
android:layout_weight="1">
<TextView android:background="#android:color/transparent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:hint="Question" android:textSize="30px"></TextView>
<ScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<WebView android:id="#+id/wvplquestion" android:layout_height="wrap_content"
android:layout_width="fill_parent"></WebView>
</ScrollView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#android:color/transparent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:layout_weight="1">
<TextView android:background="#android:color/transparent"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:hint="Select Answer" android:textSize="30px"></TextView>
<ListView android:id="#+id/lvquestion" android:layout_width="fill_parent"
android:layout_height="600dip" android:prompt="#string/selectp" />
</LinearLayout>
And my custom listview layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:padding="3dip">
<WebView android:id="#+id/weblistview" android:layout_width="fill_parent"
android:layout_height="wrap_content"></WebView>
Thanks for your help
maybe you can try to change your listview layout height. Instead of wrap content, put a fixed height. I don't know if it will be working, but you can try it. I'd a problem similar to yours and I solved it like this.
I hope it will work. Good luck ;)
Seems it mostly happens when several webviews contained into one scrollview. Seems at least first webviews should have fixed height.
My scenario is like this:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:background="#ffffeb">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp">
// Other stuff in between here..
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="12dp"
android:paddingRight="12dp">
<Button
android:id="#+id/insert_ad_ad_information_category_and_type_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="#string/insert_ad_ad_information_category_and_type_button"/>
<ListView
android:id="#+id/insert_ad_ad_information_parameters_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffeb"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:dividerHeight="0dp"
android:scrollbars="none"
android:listSelector="#android:color/transparent"/>
The problem I have is that I can't get my ListView to get the right height that I want.
I'll add a couple of components with my custom BaseAdapter class and everything there works as intended.
But when I then debug my application I can only see 1,5 out of 3 components in the list and the rest is hidden further down in the ListView.
But how can I make my ListView calculate how many components I have and get it to show all my components directly without having too scroll down?
Another thought is if I could populate any other kind of View with my BaseAdapter? Because the only reason I am using ListView is because of the setAdapter() method.
Appreciate all thoughts and comments :)
You cannot have a ListView in a ScrollView. Thats where the issue is.
As has been said you can't use ListView inside ScrollView.
If you want your listview have different types of items and scroll those with "normal" items
you do in fact need custom adapter. You can base it on BaseAdapter if you like
Adapter has to support your item types, and inflate appropriate layouts,