• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps problems with displaying my alert dialog

iust79

Lurker
Hi!
I am newbie on android and I need some help with displaying a prompt user input.

first of all, when I make a Toast display the view with my buttons dissapear and after the Toast close they don't reapear.
secondly I would like to use that AlertDialog form to get user input, process the text and then permit user to input again another phrase. How can I display again the prompt input user form (that I creat at onCreate event)?

Here is my code so far:

import android.os.Bundle;
import android.text.Editable;
import java.util.Collections;
import java.util.Arrays;
import java.util.ArrayList;

import android.view.View;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.Toast;
import android.app.AlertDialog;
import android.content.DialogInterface;

public class ShufflephraseActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

final AlertDialog.Builder alert = new AlertDialog.Builder(this);

alert.setTitle("Shuffle phrase");
alert.setMessage("Input your phrase and then click OK");

final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value1 = input.getText().toString();
if (value1.length() == 0) {

Toast.makeText(getApplicationContext(), "Please enter a text!",
Toast.LENGTH_SHORT).show();
return;
}
else {
Toast.makeText(getApplicationContext(), "Processing!",
Toast.LENGTH_SHORT).show();
dialog.dismiss();
}

}
}
);

alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton)
{
dialog.dismiss();
}
});

alert.show();

}

}
 

Attachments

  • firstview.jpg
    firstview.jpg
    69.2 KB · Views: 63
  • secondview.jpg
    secondview.jpg
    53.3 KB · Views: 65
Back
Top Bottom