The method show() .... not applicable for arguments ??

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

The method show() .... not applicable for arguments ??

Postby Patrick » Sat Jan 03, 2009 12:45 pm

Hi, I'm new to Android and have virtually no JS experience but have been working a lot with PHP & MySQL over the last year. I'm trying to get into JS & Android and have started working my way through some of the easier turorials on-line. The one I am following at the moment is an expansion of the HelloAndroid example where the intention is to eventually turn it into a simple contact book application. The tutorial is here http://learncodes.googlepages.com/ but I can't see a name to ascribe to it ... anyway just found your site so maybe you can help me.

I am using Eclipse Version: 3.4.1 & android-sdk-windows-1.0_r2.

Part of the code is ....
public void onClick(View arg0) {
// TODO Auto-generated method stub
AlertDialog.show(HelloAndroid2.this, "Save!",
"You Press Save Button, Not Yet Implemented!",
"Close", true);
}
... the idea being that at this stage in the tutorial you've only adjusted the screen to have the input contact details but can't yet save them anywhere so the 'user' gets a warning message if they hit the 'save' button but I am getting this message from Eclipse ...

"Multiple markers at this line - The method show() in the type Dialog is not applicable for the arguments (HelloAndroid2, String, String, String, boolean)"

Can anyone give me a steer as to how to get over this?

The auto correct facility within Eclipse simply removes all of the parameters which I can't see being the answer.

As an aside I'm struggling to make much sense of the Google Android on-line Reference as nothing is illustrated with examples (that I can see anyway) - is there anywhere on the web where the reference manual is illustrated?

Thanks.
Patrick.
Patrick
Freshman
Freshman
 
Posts: 3
Joined: Sat Jan 03, 2009 12:24 pm

Top

Postby MrSnowflake » Sat Jan 03, 2009 1:59 pm

JS? What are you talking about, Android uses Java not JavaScript :).

Indeed AlertDialog.show() doesn't take parameters, look through the docs, and you would have seen this. To easilly make AlertDialogs you should use AlertDialog.Builder:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. new AlertDialog.Builder(this)
  2.  
  3. .setTitle("I am cool")
  4.  
  5. .setMessage("with AlertDialog.Builder")
  6.  
  7. .show();
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

new AlertDialog.Builder() maybe should not have the 'this' there, but the rest is working code!
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Patrick » Sat Jan 03, 2009 3:43 pm

Great - thanks for your snippet, this has helped a lot and OK - yes Java not JS..... got it. The difference between the snippet you have supplied and the original tutorial is that the original warning box had an 'OK' (close) button in it but this newer version of the dialogue box does not - you have to hit the 'escape' character to return to the parent dialogue box ... how would you fix that?

Yes again - I can see from the on-line reference that show does not take parameters ....

"public AlertDialog show()
Creates a AlertDialog with the arguments supplied to this builder and show()'s the dialog."

.... but it doesn't give me any clue as to the correct syntax associated with using it - is there a site that shows illustrations of how these definitions are applied?

Thanks again for taking an interest.
Regards.
Patrick.
Patrick
Freshman
Freshman
 
Posts: 3
Joined: Sat Jan 03, 2009 12:24 pm

Postby MrSnowflake » Sat Jan 03, 2009 5:09 pm

Patrick wrote:The difference between the snippet you have supplied and the original tutorial is that the original warning box had an 'OK' (close) button in it but this newer version of the dialogue box does not - you have to hit the 'escape' character to return to the parent dialogue box ... how would you fix that?
For Android it's accepted to leave out the Close button as the back button has the same effect. If you still want the Close button you should use setNeutralButton(String, onClickListener);

Patrick wrote:Yes again - I can see from the on-line reference that show does not take parameters ....

"public AlertDialog show()
Creates a AlertDialog with the arguments supplied to this builder and show()'s the dialog."

.... but it doesn't give me any clue as to the correct syntax associated with using it - is there a site that shows illustrations of how these definitions are applied?

Thanks again for taking an interest.
Regards.
Patrick.
Don't think there's a site, but since there's a internal Builder class in the docs, that rang a bell with me :).
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Patrick » Sat Jan 03, 2009 6:32 pm

OK - Thanks again.
Patrick
Freshman
Freshman
 
Posts: 3
Joined: Sat Jan 03, 2009 12:24 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 5 guests