ExpandableListView groupIndicator is disabled with CheckBox - android

I am trying to use an ExpandableListView and in the group view I need a textview and a checkbox (checkbox is on the right).
The issue I am seeing is that the groupIndicator view is no longer tappable - tapping on it does not expand the group anymore. If I remove the checkbox, then groupIndicator receives events and group is expandable. The same happens with another View that receives some kind of focus, for example an EditText.
Here is the layout of the fragment containing the ExpandableListView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ExpandableListView
android:id="#+id/categoryList"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ExpandableListView>
</RelativeLayout>
The layout of the group:
<?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="match_parent"
android:background="#color/white_background"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtCategoryGroup"
android:layout_width="0dip"
android:layout_height="#dimen/items_filter_group_height"
android:layout_marginLeft="45dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:textIsSelectable="false" />
<!--
<CheckBox
android:id="#+id/cbGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</CheckBox>
-->
</LinearLayout>
... and, if you find useful, the layout of the child:
<?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="#dimen/items_filter_child_height"
android:background="#color/white_background"
android:orientation="horizontal" >
<CheckBox
android:id="#+id/cbProperty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</CheckBox>
</LinearLayout>
Attached is the layout I am getting if the CheckBox is un-commented:
Tapping on the red-marked groupIndicator doesn't expand the group. Leaving it commented expands it. As said above: what is strange is that the same happens with an EditText.
The work-around is to set the groupIndicator to #null and set the TextView's compound left drawable to something relevant in response to ExpandableListView#OnGroupCollapseListener and #OnGroupExpandListener, but I am not that happy writing code for something like that.
Thanks!

Put android:descendantFocusability="blocksDescendants" in both LinearLayout of the group and child.

Related

ListView Selector on Specific Element Within ListView View

I'm having a problem where I want each subchild of a view for a listview to have it's own custom selector. There are a few solutions already but none of them seem to work at all for me. Here's my xml for the listview and individual view. Does anyone know specifically what I need to do? Right now If I can get show_group_actions and action_calendar to have separate selectors working I'd be quite happy...
<?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:descendantFocusability="afterDescendants"
android:orientation="vertical">
<LinearLayout
android:id="#+id/action_show_group_actions"
style="#style/AppTheme.NavigationDrawer.Row"
android:paddingRight="0dp"
>
<TextView
android:id="#+id/group_name"
style="#style/AppTheme.NavigationDrawer.Row.TextView"
android:text="#string/label_my_groups"
/>
<RelativeLayout
style="#style/AppTheme.NavigationDrawer.Group.OpenClose"
>
<me.magneto.groups.views.IconView
android:id="#+id/action_show_group_actions_arrow"
style="#style/AppTheme.NavigationDrawer.Group.OpenClose.Arrow"
android:text="#string/icon_chevron_down"/>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/action_calendar"
style="#style/AppTheme.NavigationDrawer.Group.Row"
>
<me.magneto.groups.views.IconView
style="#style/AppTheme.NavigationDrawer.Group.IconView"
android:text="#string/icon_calendar"
/>
<TextView
style="#style/AppTheme.NavigationDrawer.Row.TextView"
android:text="#string/label_calendar"/>
</LinearLayout>
</LinearLayout>
<ListView
android:id="#+id/navigation_drawer_list_view"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:listSelector="#null"
android:background="#color/navigation_primary_background"
/>

Creating an Android Layout with 2 resizing views

In my layout, I need a header, a list-view, and a footer with a TextView. The TextView needs to be resizable to up to 5 lines. Think facebook chat, where you have the blue header with the name of your friend, the middle content pane, and a text box down below, that grows as you type stuff in:
[header] a fragment that takes up about 50dp
[content]
[content]
[content]
[content] something like a ViewGroup with a ListView in it
[content]
[content]
[content]
[footer] a ViewGroup that contains an EditText and Buttons
I've tried all sorts of different layout settings, but can't get it right. Either the footer takes up all the space, or the content covers the footer.
Here's what I have so far:
<LinearLayout ...>
<!-- Slot to put Header fragment in -->
<FrameLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Here's where the content goes. This is supposed to be a ListView
inserted as a fragment -->
<FrameLayout
android:id="#+id/content"
... />
<include
android:id="#+id/footer"
... />
</LinearLayout>
I left out the layout_width and layout_height values empty, because I don't know what to set them to.
UPDATES
Initially, I thought the problem was because my EditText was set to maxLines=5 and TextMultiline, but I tried removing everything but one button with a hardcoded height, and the insert still covered everything. I also tried setting <footer below="content"> but then content just covered footer
The problem was that the footer layout included is another RelativeLayout. The footer layout contains elements that set layout_alignParentBottom="true", which made the footer layout take up the entire screen. I have no idea why it would do that, but that's what happens.
For creating a UI like this create a layout
header.xml
<?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="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="xyz"
android:textSize="10dp" />
</LinearLayout>
for footer:
footer.xml
<?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="horizontal" >
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="xyz"
android:textSize="10dp" />
</LinearLayout>
Create another layout that will contain listView as you said :
main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
**<include layout="#layout/header.xml" android:layout_alignParentTop="true"/>**
<ListView
android:id="#+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
>
</ListView>
**<include layout="#layout/footer.xml" android:layout_below="#+id/listview" android:layout_alignParentBottom="true"/>**
</RelativeLayout>
check this...I hope it helps. At the moment I have defined an array.xml in Values folder with some empty entries for ListView. You will have to handle it with code.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:text="HEADER" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/chats"
android:layout_weight="1">
</ListView>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lines="5"
android:inputType="textMultiLine"
android:hint=" Please enter your Chat" />
</LinearLayout>

Making ListView scrolled with other items

http://realdevs.tistory.com/entry/asdf
↑ Picture.
I have a problem when I use ListView.
As the screen is full of widgets, I would like the ListView's items to be scrolled with other items in the layout.
On the picture, the blue one is a widget on the layout, and the red ones are the items of ListView.
When I scroll up the items, they move, but the blue one doesn't.
How can I make it to move together with ListView as it is an item in ListView?
you an add your blue layout as your listView header.
this will help you in adding a layout as header.
Simply add that blue part in scrollview
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
your layout
........
</ScrollView>
From your pic in http://realdevs.tistory.com/entry/asdf
I'm implement in coding xml this.
<?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="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#e0e0e0"
android:orientation="vertical" >
<!-- this layout add your other items. I'm exam add Button -->
<Button
android:id="#+id/butonTop"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:text="Top Button" />
</LinearLayout>
<!-- ListView in bottom screen and can auto scroll. -->
<ListView
android:id="#+id/dataListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:drawSelectorOnTop="false" >
</ListView>
</LinearLayout>

Button at Bottom

Im not very good in creating android layouts so I am not able to align the button to the bottom in the MainView.
Picture:
Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="#+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical">
<ListView android:id="#+id/lv_pizza" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"></ListView>
<Button android:layout_width="fill_parent" android:id="#+id/bt_add"
android:layout_height="wrap_content" android:text="hinzufügen"></Button>
<RelativeLayout android:layout_width="fill_parent" android:id="#+id/relativeLayout2" android:layout_height="fill_parent">
</RelativeLayout>
</LinearLayout>
Please help
This works for a linear layout, note the layout_weight 1 on the list -- that's what pushes the button to the bottom:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView android:id="#+id/lv_pizza"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button android:id="#+id/bt_add"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="hinzufügen" />
</LinearLayout>
This then looks like this in the UI editor:
Hi you can set like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="#+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical">
<ListView android:id="#+id/lv_pizza" android:layout_width="fill_parent"
android:layout_above="#+id/bt_add" android:layout_height="fill_parent" ></ListView>
<Button android:layout_width="fill_parent" android:id="#+id/bt_add"
android:layout_gravity="bottom" android:layout_height="wrap_content" android:text="hinzufügen"></Button>
</RelativeLayout>
Removing the RelativeLayout will push the button to bottom of the screen...
Use a layout_weight for the components inside the LinearLayout. If the ListView has a weight of 1.0, it should push the button to the bottom. I've done this with a ScrollLayout and it works well, allowing the component inside the scroll layout to actually scroll. You could put your ListView into a ScrollLayout to let it grow beyond the visible size.
Also, the second relativelayout also isn't necessary as it doesn't add anything.
You can set a marginTop in the Button until the bottom or change the layout to relative and set the position.

uable to set layout of a view after adding it in WebView

I have added a view into WebView , but the problem is after adding a view using webView.addView(myview) the layout of the myview resides on the top of the screen though i have set android:layout_gravity="bottom" in myviews's layout resource file.
so far i have tired following things
myview_layout.xml
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/mc_track_icon"
>
</ImageView>
</LinearLayout>
i tried the relative layout too
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/mc_track_icon"
>
</ImageView>
</RelativeLayout>
Even i have tried to set the layout explicitly in code also
webView.add(myView,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,Gravity.BOTTOM));
But the ImageView is visible on the top left corner only.
Maybe using a Relative layout would be better.Then in the yourlayout.xml add
android:layout_alignParentBottom="true" >

Categories

Resources