[TinyTut] - Displaying a Messagebox

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Can't get this to work

Postby cre » Mon Nov 03, 2008 3:21 am

Nothing appears on the screen.
Can you give me a complete example. Eclipse gave me an error for not including the void which you did not have in your example
Here's my code...
thks,
cre
___________________

package com.adndroid.something;

import android.app.Activity;
import android.os.Bundle;

public class some extends Activity {
/** Called when the activity is first created. */
void showAlert(CharSequence title, CharSequence message, CharSequence buttonText, boolean cancelable){};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

initControls();

}



private void initControls()

{

showAlert("A funny title", "MessageBoxes rule extremely!", "Hit Me!",false);

}

}
cre
Freshman
Freshman
 
Posts: 5
Joined: Mon Nov 03, 2008 3:04 am

Top

Re: [TinyTut] - Displaying a Messagebox

Postby manish » Fri Jun 12, 2009 10:35 am

plusminus wrote:
[TinyTut] - Displaying a Messagebox


Hi,

I am getting an error that showAlert function is not presnent in android.

What you learn: You will learn how easy it is, to display a MessageBox (showAlert(...)).

Difficulty: 0 of 5 :roll:

What it will look like:
Image


Description
This has been a very common question, as in "normal" Java a MessageBox was displayed with code like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. JOptionPane.showMessageDialog(...);
Parsed in 0.029 seconds, using GeSHi 1.0.8.4

in Android you can do almost the same with the following code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. showAlert("A funny title", "MessageBoxes rule extremely!", "Hit Me!", false);
  2. // Where the definition of the function is (simplest of 4 different):
  3. showAlert(CharSequence title, CharSequence message, CharSequence buttonText, boolean cancelable)
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
manish
Junior Developer
Junior Developer
 
Posts: 21
Joined: Thu Feb 05, 2009 1:06 pm

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests