Dewsworld
Dewsworld

Reputation: 14033

Android Activity not working

I have this activity,

package org.dewsworld.ui;

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

public class Main extends Activity {

    TextView textView ;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        textView = (TextView) findViewById(R.id.textView1) ;
        textView.setText("hello ") ;
    }
    
}

And main.xml is

<?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" android:id="@+id/textView1">
    <TextView android:layout_height="wrap_content" android:id="@+id/textView1"
        android:layout_width="wrap_content" android:text="TextView" />
</LinearLayout>

And the logcat is

And I can't find the error... :(

Upvotes: 0

Views: 278

Answers (2)

jazz
jazz

Reputation: 1216

<?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" >
    <TextView android:layout_height="wrap_content" android:id="@+id/textView1"
        android:layout_width="wrap_content" android:text="TextView" />
</LinearLayout>

try now

Upvotes: 4

Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

You have 2 views with the same ids Linearlayout and TextView. remove the id for the LinearLayout and try it again. It will work.

Upvotes: 3

Related Questions