javaandroidresponsibility

Android HelloWorld response


I know that the heading of this thread sound silly, but I can not repair my code.

package HelloAndroid;

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

public class HelloAndroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView view = new TextView(this);
    view.setText("LOL View Working!");
    setContentView(view);
}
}

My problem is that I'm getting error in emulator: process not reponding or something similair. Why?! This application is so small so why it does not works?! Please help me.

EDIT:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="HelloAndroid.Main"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".HelloAndroidActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Solution

  • in AndroidManifest.xml, replace:

    package="HelloAndroid.Main"
    

    with:

    package="HelloAndroid"
    

    or move your java source file, into HelloAndroid.Main package by replacing the first line with:

    package HelloAndroid.Main;