Advertisement
Guest User

Untitled

a guest
Jul 8th, 2012
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. import android.app.Activity;
  2. import android.app.AlertDialog;
  3. import android.content.DialogInterface;
  4. import android.os.Bundle;
  5. import android.view.LayoutInflater;
  6. import android.view.View;
  7. import android.view.ViewGroup;
  8. import android.widget.TextView;
  9.  
  10. public class TestActivity extends Activity {
  11. private AlertDialog.Builder dlgBuilder;
  12. private LayoutInflater inflater;
  13.  
  14. private View dlgLayout;
  15. private TextView dlgText;
  16. private int count;
  17.  
  18. @Override
  19. public void onCreate(Bundle savedInstanceState) {
  20. super.onCreate(savedInstanceState);
  21. inflater = LayoutInflater.from(TestActivity.this);
  22. dlgLayout = inflater.inflate(R.layout.dialog_layout, (ViewGroup)findViewById(R.id.dialog_linearLayout));
  23. dlgText = (TextView)findViewById(R.id.dialog_text);
  24. count = 0;
  25. dlgBuilder = new AlertDialog.Builder(this);
  26. dlgBuilder.setView(dlgLayout);
  27. setDialog(dlgBuilder);
  28. }
  29.  
  30. @Override
  31. public void onStart() {
  32. super.onStart();
  33. dlgBuilder.show();
  34. }
  35.  
  36. private void setDialog(AlertDialog.Builder dlgBuilder) {
  37. dlgBuilder.setCancelable(false);
  38. dlgBuilder.setPositiveButton("changeText", new DialogInterface.OnClickListener() {
  39. public void onClick(DialogInterface dialog, int id) {
  40. switch (count) {
  41. case 0:
  42. dlgText.setText("now loading...");
  43. count = 1;
  44. break;
  45. case 1:
  46. dlgText.setText("completed");
  47. count = 2;
  48. break;
  49. case 2:
  50. dlgText.setText("please wait...");
  51. count = 0;
  52. break;
  53. default:
  54. break;
  55. }
  56. }
  57. });
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement