Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus 6 | Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old February 28th, 2011, 12:35 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Feb 2011
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default I can not run an android application

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

Advertisements
trandroid is offline  
Reply With Quote
sponsored links
Old February 28th, 2011, 10:44 AM   #2 (permalink)
New Member
 
Join Date: Feb 2011
Posts: 10
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you post your code on here please so we can take a look?
matt20687 is offline  
Reply With Quote
Old February 28th, 2011, 11:23 PM   #3 (permalink)
New Member
Thread Author (OP)
 
Join Date: Feb 2011
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

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"
androidrientation="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" androidnClick="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
trandroid is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:27 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.