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. How to install apk in device using window machine

Hi,

I want to know how to install apk in device using window machine.

Thanks and Regards,
Sohan Badaya

-- 

2. TabActivity and GLSurfaceView

Hi,

In my app, i have a TabActivity with 2 tabs.
-Tab1 displays a web page (with WebViewClient)
-Tab2 displays contains a FrameLayout with 2 SurfaceViews :

The first SurfaceView contains the videocapture from the camera.
The second surfaceview is a GLSurfaceView.

The app works fine. I can switch from a tab to another.

But i want optimise my app :
When i switch from Tab2 to Tab1, i want to "pause" my render.
So in the Tab2 activity i reimplement

 @Override
    public void onPause() {
        Log.i(LOGTAG, "onPause");
        super.onPause();
        myGLSurfaceView.onPause();

    }
    @Override
    public void onResume(){
        Log.i(LOGTAG, "onResume");
        super.onResume();
        myGLSurfaceView.onResume();
    }


With this code, my render is stopped, but when i reswitch in the Tab2,
the GLSurfaceView is recreated (onSurfaceCreated(GL10 gl, EGLConfig
config) is called). The surface is re-created but i have never seen a
surfaceDestroyed call.

What's wrong?

-- 

3. What is drawable-hdpi, drawable-ldpi and drawable-mdpi ?

4. Regarding the surfaceview

5. How to disable pop up blocker in emulator 2.1

6. How to change target build on Android project?

7. Leaked Window changing orientation with SubMenu