add EditText with backgroundtxt to child of Expandable list?


Last Updated:

  1. Timo

    Timo New Member This Topic's Starter

    Joined:
    Feb 15, 2009
    Messages:
    2
    Likes Received:
    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?


     

    Attached Files:


    Advertisement
  2. Timo

    Timo New Member This Topic's Starter

    Joined:
    Feb 15, 2009
    Messages:
    2
    Likes Received:
    0
    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 (Text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <ScrollView
    3. android:id="@+id/widget28"
    4. android:layout_width="fill_parent"
    5. android:layout_height="fill_parent"
    6. xmlns:android="http://schemas.android.com/apk/res/android"
    7. >
    8. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    9.     android:layout_width="fill_parent"
    10.     android:layout_height="wrap_content"
    11.     android:orientation="vertical">
    12.    
    13.    
    14. <LinearLayout
    15.         android:layout_width="fill_parent"
    16.         android:layout_height="wrap_content"
    17.         android:addStatesFromChildren="true"
    18.         android:gravity="center_vertical"
    19.         android:paddingRight="0dip"
    20.         android:background="@android:drawable/edit_text">
    21.  
    22.         <!--
    23.             TextView label goes at the left.
    24.         -->
    25.         <TextView
    26.             android:layout_width="wrap_content"
    27.             android:layout_height="wrap_content"
    28.             android:text="Lat: "
    29.             android:textAppearance="?android:attr/textAppearanceLargeInverse"
    30.         />
    31.  
    32.         <!--
    33.             EditText goes in between.
    34.         -->
    35.         <EditText
    36.             android:layout_width="wrap_content"
    37.             android:layout_height="wrap_content"
    38.             android:layout_weight="1"
    39.             android:singleLine="true"
    40.             android:background="@null"
    41.         />
    42. </LinearLayout>
    43.  
    44. <LinearLayout
    45.         android:layout_width="fill_parent"
    46.         android:layout_height="wrap_content"
    47.         android:addStatesFromChildren="true"
    48.         android:gravity="center_vertical"
    49.         android:paddingRight="0dip"
    50.         android:background="@android:drawable/edit_text">
    51.  
    52.         <!--
    53.             TextView label goes at the left.
    54.         -->
    55.         <TextView
    56.             android:layout_width="wrap_content"
    57.             android:layout_height="wrap_content"
    58.             android:text="Lat: "
    59.             android:textAppearance="?android:attr/textAppearanceLargeInverse"
    60.         />
    61.  
    62.         <!--
    63.             EditText goes in between.
    64.         -->
    65.         <EditText
    66.             android:layout_width="wrap_content"
    67.             android:layout_height="wrap_content"
    68.             android:layout_weight="1"
    69.             android:singleLine="true"
    70.             android:background="@null"
    71.         />
    72. </LinearLayout>
    73.  
    74. </LinearLayout>
    75. </ScrollView>
     

Share This Page

Loading...