• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps add EditText with backgroundtxt to child of Expandable list?

Timo

Lurker
Feb 15, 2009
2
0
I have been trying to use the ExpandableList from the API-demos
(see example API demos -->views / expandable lists / custom adapter)
and alter it so the childs will display a EditText which has non-editable text as a backgound
(see example API demos --> views / layouts / linearlayouts / 10.BackgroundImage).

I am not able to get it to work.
Who can help me out with this one?


 

Attachments

  • screencap1.jpg
    screencap1.jpg
    5.8 KB · Views: 208
  • screencap2.jpg
    screencap2.jpg
    5.6 KB · Views: 201
I seem to have figured it out myself.
I was looking in the wrong area.
The ListView is not made for displaying EditText.

My Solution was to use a ScrollView instead of a ListView:


Code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<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:addStatesFromChildren="true"
        android:gravity="center_vertical"
        android:paddingRight="0dip"
        android:background="@android:drawable/edit_text">

        <!--
            TextView label goes at the left.
        -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lat: "
            android:textAppearance="?android:attr/textAppearanceLargeInverse"
        />

        <!--
            EditText goes in between.
        -->
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true"
            android:background="@null"
        />
</LinearLayout>

<LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:addStatesFromChildren="true"
        android:gravity="center_vertical"
        android:paddingRight="0dip"
        android:background="@android:drawable/edit_text">

        <!--
            TextView label goes at the left.
        -->
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lat: "
            android:textAppearance="?android:attr/textAppearanceLargeInverse"
        />

        <!--
            EditText goes in between.
        -->
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:singleLine="true"
            android:background="@null"
        />
</LinearLayout>

</LinearLayout>
</ScrollView>
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones