Reputation: 15
I want to change position of list item button and after I move the button to the position I want the emulator gives me an error.. So can anybody tell my why this code works fine:
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/messages_list_item"
android:layout_height="wrap_content"
android:gravity="left|center"
android:layout_width="fill_parent" >
<Button
android:id="@+id/send_message_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/destination"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
<TextView android:id="@+id/message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
And if I move Button element to the bottom like this:
list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/messages_list_item"
android:layout_height="wrap_content"
android:gravity="left|center"
android:layout_width="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/destination"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
<TextView android:id="@+id/message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<Button
android:id="@+id/send_message_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/send" />
</LinearLayout>
It does not launch on the emulator?
Here is my activity view:
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/base_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/messages_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
What am I missing?
Upvotes: 0
Views: 297
Reputation: 4345
you should be see the list_item.xml
file. You wrote the code of Button to times and close the </LinearLayout>
one times more. I think it give error in list_item.xml
.
Upvotes: 1
Reputation: 1706
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/messages_list_item"
android:layout_height="wrap_content"
android:gravity="left|center"
android:layout_width="fill_parent" >
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/destination"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
<TextView android:id="@+id/message_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<Button
android:id="@+id/send_message_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/send" />
</LinearLayout>
<Button
android:id="@+id/send_message_button"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="@string/send" />
</LinearLayout>
In the second xml, I think you doubled the 6 last lines... So you close too much LinearLayout.
Upvotes: 1