showing error while adding editview in linearlayout.

by Shalin » Fri, 07 Aug 2009 12:57:50 GMT


Sponsored Links
 Hello friend, when I am adding  editview in linearlayout I am getting
an error like this. My XML file as under. I am trying to add editview
above listview.
Error is
UnsupportedOperatioException: addView(View,LayoutParams) is not
supported in adapterview.

XMLfile:
<ListView android:id="@+id/android:list"
               android:layout_width="fill_parent"
              android:layout_height="100dp"
              android:background="#ffffff" android:layout_weight="3" >
<TextView
                android:id="@+id/str"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="#ecff20">
        </TextView>

        <TextView
                android:id="@+id/count"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="#2f116f">
        </TextView>

        <LinearLayout  xmlns:android=" http://schemas.android.com/apk/res/ 
android"
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
        android:background="#cccccc"
        android:textColor="#ffffff"
        android:padding="3dp"
        android:gravity="bottom"
                android:layout_weight="1"
                >
            <EditText
                android:id="@+id/txt"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="@android:drawable/editbox_background"
                android:hint="Type to compose"
                android:minHeight="30dp"
                android:maxHeight="100dp"
                android:layout_weight="1"
        />

            <Button
                android:id="@+id/btn"
                android:layout_width="120dp"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:text="Send SMS"
            />
        </LinearLayout>

</LinearLayout>

Thanks in advance
--~--~---------~--~----~------------~-------~--~----~



showing error while adding editview in linearlayout.

by Gibson » Fri, 07 Aug 2009 17:38:06 GMT


 The error is because you defined a TextView inside a ListView. You
know ListView first is an AdapterView. You cannot add a view into
AdapterView because it is not supported. What you can do is to define
an Adapter(such as ArrayAdapter) then set the adapter into the
ListView. Hope this can help you.



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


showing error while adding editview in linearlayout.

by Shalin » Fri, 07 Aug 2009 18:45:05 GMT


 ut here I can access TextView in my code. Its isn't giving any error
or exception, But when I am trying to add EdtiText above ListView than
it's giving error. My actual XML as under. Declaration of LinearLayout
is Missing at very first.

<?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">

******************I want EditText here*******************************

<ListView android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:background="#ffffff" android:layout_weight="3"
<TextView
android:id="@+id/str"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#ecff20">
</TextView>
<TextView
android:id="@+id/count"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#2f116f">
</TextView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/
res/
android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#cccccc"
android:textColor="#ffffff"
android:padding="3dp"
android:gravity="bottom"
android:layout_weight="1"
>
<EditText
android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:drawable/
editbox_background"
android:hint="Type to compose"
android:minHeight="30dp"
android:maxHeight="100dp"
android:layout_weight="1"
/>
<Button
android:id="@+id/btn"
android:layout_width="120dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Send SMS"
/>
</LinearLayout>
</LinearLayout>

On Aug 7, 2:37am, Gibson <zclgib...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



showing error while adding editview in linearlayout.

by Shalin » Fri, 07 Aug 2009 18:58:54 GMT


 ere, I am closing that ListView too.But still I am getting problem.In
xml file I am writing EditText above ListView, that's showing EditText
but when I am trying to setting or getting value in that EditText it's
giving nullpointer exception

On Aug 7, 3:44am, Shalin <smehta...@yahoo.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



showing error while adding editview in linearlayout.

by Shalin » Fri, 07 Aug 2009 19:13:43 GMT


 roblem resolved. Thanks for replying.

On Aug 7, 3:58am, Shalin <smehta...@yahoo.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Preventing Multiple AppWidget Instances

Is there a way to prevent multiple instances of an appwidget from being
installed on the home screen?  I do not do any special handling, nor is
it intended, for there to multiple instances.  Therefore, I should
probably prevent it or at least warn about it.  Is this possible?

-- 
Jake Colman -- Android Tinkerer

-- 

2. 2.3.3 NFC Tag app breaks 2.3.2 NFC apps

The in built Tags app in 2.3.3 appears to use the TECH_DISCOVERED action 
which means that will obscure any 2.3.2 apps that use TAG_DISCOVERED...
This is of course dependant on the TECHs that the Tags app is filtering - is 
there any public list of which ones?

-- 

3. In-app purchase, how to test it on Android 2.3.3?

4. Android 2.3: Music content providers for artists, albums and songs

5. mohon pencerahan

6. How To Determine Which Dialog Was Dismissed

7. In-App Payments with Single-Click Checkout