Layout Fails!

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Layout Fails!

Postby droozen » Thu Feb 26, 2009 5:41 pm

I seem to be having troubles when trying to set this layout in setContextView(). I just fail, but I can't tell any problems with the layout. Any ideas?

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.    android:orientation="vertical"
  7.  
  8.    android:padding="10dip"
  9.  
  10.    android:layout_width="fill_parent"
  11.  
  12.    android:layout_height="wrap_content">
  13.  
  14.  
  15.  
  16.         <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
  17.  
  18.                 <Button android:id ="@+id/startHour"
  19.  
  20.                  android:text="@string/start_time"
  21.  
  22.                  android:layout_width="wrap_content"
  23.  
  24.                  android:layout_height="wrap_content"
  25.  
  26.                 />
  27.  
  28.                 <Button android:id ="@+id/stopHour"
  29.  
  30.                  android:text="@string/stop_time"
  31.  
  32.                  android:layout_width="wrap_content"
  33.  
  34.                  android:layout_height="wrap_content"
  35.  
  36.                 />
  37.  
  38.         </LinearLayout>
  39.  
  40.         <TextView android:id="@+id/startTime"
  41.  
  42.        android:layout_width="fill_parent"
  43.  
  44.        android:layout_height="wrap_content"
  45.  
  46.        android:layout_marginTop="3dip" />
  47.  
  48.     <View
  49.  
  50.        android:layout_width="fill_parent"
  51.  
  52.        android:layout_height="2dip"
  53.  
  54.        android:background="#FFFFFFFF" />
  55.  
  56.        
  57.  
  58.     <ListView android:id="@+id/list"
  59.  
  60.        android:layout_width="wrap_content"
  61.  
  62.        android:layout_height="wrap_content"/>
  63.  
  64.  
  65.  
  66.  
  67.  
  68. </LinearLayout>
  69.  
  70.  
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
droozen
Developer
Developer
 
Posts: 45
Joined: Wed Feb 25, 2009 10:10 pm

Top

Postby mdownie » Thu Feb 26, 2009 10:56 pm

Are you getting an error when trying to load it or are you just getting a blank screen?
mdownie
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Nov 25, 2008 6:54 pm
Location: Las Vegas

Postby droozen » Thu Feb 26, 2009 10:59 pm

An error pops up when the setContentView is called saying that my app quits unexpectedly.
droozen
Developer
Developer
 
Posts: 45
Joined: Wed Feb 25, 2009 10:10 pm

Are you sure?

Postby mdownie » Thu Feb 26, 2009 11:28 pm

Are you sure that it has the error right when the layout is loaded or some code after you load it? The layout itself loads fine for me.
mdownie
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Nov 25, 2008 6:54 pm
Location: Las Vegas

Postby droozen » Thu Feb 26, 2009 11:38 pm

It's right when I load it. I've stepped through it with a debugger. I think I've finally figured it out, though.

I think I reread the Notepad tutorial to find something I missed the first time. (I bet your activity doesn't extend ListActivity for it to have run fine.) When your activity extends ListActivity and you try to define a layout for it, the layout must have a ListView with android:id="@android:id/list" parameter. Mine, here, was android:id="@+id/list".

Pretty sure that was my problem. At least it's working for me now.
droozen
Developer
Developer
 
Posts: 45
Joined: Wed Feb 25, 2009 10:10 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 9 guests