• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps I can not run an android application

trandroid

Lurker
hi,
I wrote an simlpe android application. When I run the application only writes "android" in emulator. why the application does not start?
thanks
 
this is my java code,

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class helloMenu extends Activity {


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

public void openMyDialog(View view) {
showDialog(10);
}


protected Dialog onCreateDialog(int id) {
switch (id) {
case 10:

android.app.AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to close the application?")
.setCancelable(true)
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,
int which) {

helloMenu.this.finish();
}
})
.setNegativeButton("No",
new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog,
int which) {
Toast.makeText(getApplicationContext(),
"Application is running...",
Toast.LENGTH_SHORT).show();
}
});
AlertDialog dialog = builder.create();
dialog.show();

}
return super.onCreateDialog(id);
}
}



this is my main.xml code

<?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_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:layout_width="wrap_content" android:text="Alert Dialog" android:id="@+id/button1" android:layout_height="wrap_content" android:onClick="openMyDialog"></Button>
</LinearLayout>


I'm not sure, but the reason for not working is not about code. I'm using eclipse. may be the problem with the settings.
thanks
 
Back
Top Bottom