[Beginner] Layout Problem

Last Updated:

  1. MCiD

    MCiD New Member

    Hi all,
    I have a quit simple problem:
    I would like to have an TextView element above a List.
    So I got the list working using the Tutorials. And of course TextView is now problem using LinearLayout and make it a child of it. :)

    But how can I have a LinearLayout and a TextView and a List as child? :confused: Is there any approach? If there is an example I would be very happy, but I searched quit long, so I don't think there is one already available.

    Also If there is information about how to combine to views I would be very happy.

    Thank you.


  2. MCiD

    MCiD New Member


    I managed it, to have a TextView and a ListView within a LinearLayout. But every time I want to add an Element I get the Resources$NotFoundException. :mad:

    This is my layout (remote.xml):
    Code (Text):
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    4.               android:layout_width="fill_parent"
    5.               android:layout_height="fill_parent"
    6.               android:orientation="vertical" >
    7.     <Button android:id="@+id/add"
    8.             ...some Button />              
    9.     <TextView android:id="@+id/currentDirectory"
    10.               ...some Text/>
    11.     <ListView android:id="@+id/list"
    12.            android:layout_width="fill_parent"
    13.            android:layout_height="wrap_content" />
    14.     <TextView xmlns:android="http://schemas.android.com/apk/res/android"
    15.         android:id="@+id/element"
    16.         android:layout_width="fill_parent"
    17.         android:layout_height="fill_parent"
    18.         android:padding="10dp"
    19.         android:textSize="16sp" >
    20.         </TextView>
    21. </LinearLayout>
    The ListView should be the list, and the TextView with id element should be the elements of the list.

    Here follows the java code:
    Code (Text):
    2.         setContentView(R.layout.remote);
    3.         System.out.println("Done: setContentView(R.layout.remote);");
    4.         ListView list = (ListView)findViewById(R.id.list);        
    5.         adapter = new ArrayAdapter<String>(this, R.id.element, R.id.list);
    6.         list.setAdapter(adapter);
    7.         directoryField = (TextView)findViewById(R.id.currentDirectory);
    Is set in the click event of the button to add an Element:
    Code (Text):
    2.     public void onClick(View v) {
    3.         adapter.add("hallo");        
    4.     }
    Every time this code is executed I get:
    D/AndroidRuntime(12539): Shutting down VM
    W/dalvikvm(12539): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    E/AndroidRuntime(12539): FATAL EXCEPTION: main
    E/AndroidRuntime(12539): android.content.res.Resources$NotFoundException: Resource ID #0x7f05000a type #0x12 is not valid

    Please, if anybody as an Idea what the problem could be I am glad.

    Thank you,


Share This Page