views:

172

answers:

1

All I'm trying to do is open a very simple application that is supposed to do nothing but display an imageView above a textView. The application worked fine until I added the imageView so I'm assuming my problem has something to do with that.

Here is the code:

package com.isi.sa;

import android.app.Activity;
import android.os.Bundle;

public class SimpleAssessment extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
    }
}

Here is my layout -> main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView
        android:layout_width="fill_parent"
        android:src="@drawable/isi_logo"/>

    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:text="@string/hello"
        android:background="@color/white"
        android:textColor="@color/black"/>
</LinearLayout>

When I try and run the app in Eclipse through the Emulator the emulator gives me the following error:

The application Application Name (process.com.isi.sa) has stopped unexpectedly. Please try again.

The Console log in Eclipse shows the following messages:

[2010-04-16 11:08:44 - SimpleAssessment] ------------------------------
[2010-04-16 11:08:44 - SimpleAssessment] Android Launch!
[2010-04-16 11:08:44 - SimpleAssessment] adb is running normally.
[2010-04-16 11:08:44 - SimpleAssessment] Performing com.isi.sa.SimpleAssessment activity launch
[2010-04-16 11:08:44 - SimpleAssessment] Automatic Target Mode: launching new emulator with compatible AVD 'my_avd'
[2010-04-16 11:08:44 - SimpleAssessment] Launching a new emulator with Virtual Device 'my_avd'
[2010-04-16 11:08:47 - SimpleAssessment] New emulator found: emulator-5554
[2010-04-16 11:08:47 - SimpleAssessment] Waiting for HOME ('android.process.acore') to be launched...
[2010-04-16 11:09:31 - SimpleAssessment] WARNING: Application does not specify an API level requirement!
[2010-04-16 11:09:31 - SimpleAssessment] Device API version is 3 (Android 1.5)
[2010-04-16 11:09:31 - SimpleAssessment] HOME is up on device 'emulator-5554'
[2010-04-16 11:09:31 - SimpleAssessment] Uploading SimpleAssessment.apk onto device 'emulator-5554'
[2010-04-16 11:09:31 - SimpleAssessment] Installing SimpleAssessment.apk...
[2010-04-16 11:10:04 - SimpleAssessment] Success!
[2010-04-16 11:10:04 - SimpleAssessment] Starting activity com.isi.sa.SimpleAssessment on device 
[2010-04-16 11:10:09 - SimpleAssessment] ActivityManager: Starting: Intent { action=android.intent.action.MAIN categories={android.intent.category.LAUNCHER} comp={com.isi.sa/com.isi.sa.SimpleAssessment} }

Thanks in advance for the help!

A: 

ImageView is missing a layout_height and you can't have both of them as "fill_parent". You should use a RelativeLayout or use absolute heights/widths.

BrennaSoft
The first part is the issue. Every element requires both a layout_height and a layout width. Setting the ImageView's layout_height to "wrap_content" looks like what is intended.
jqpubliq
That was my problem. Thanks for the help.
Ryan