I can not run an android application


Last Updated: 2011-03-01 05:23:58
  1. trandroid

    trandroid New Member

    hi,
    I wrote an simlpe android application. When I run the application only writes "android" in emulator. why the application does not start?
    thanks

    Advertisement
  2. matt20687

    matt20687 Member

    Can you post your code on here please so we can take a look?
  3. trandroid

    trandroid New Member

    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:eek:rientation="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:eek:nClick="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

Share This Page