Ok, let me begin by pointing out I'm an absolute beginner with java and android although I do know php and have dabbled with C, Python and a few other languages. Still, I'm a bit in over my head at the moment.
Anyway, I've created a new android project in eclipse, a bit of a hello world and I'd like a dialog to pop up with a cusom message and an OK button to dismiss the dialog.
I have imported AlertDialog into my action:
import android.app.AlertDialog;
and then instantiated an AlertDialog object:
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
but then Eclipse throws up an error when I try and set a property on alertDialog:
alertDialog.setTitle = "Debug";
which prevents my ap开发者_如何学Pythonp from compiling. I'm at a bit of a loss as I've looked at several guides online and can't seem to see what I'm doing wrong.
Also, I understand there are better ways of throwing up a dialog including putting them in an action, but I simply want this for some quick debugging feedback and to just learn what the hell is going on :)
Full source code for this activity is here: http://dl.dropbox.com/u/3331622/activity.txt
Thanks for your help!
You'll have to remember the different syntax in java:
alertDialog.setTitle("Debug");
You are using a method in the class AlertDialog, not accessing a public field.
精彩评论