H4T3D

Main Menue

Dec 17th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. package com.hatinc.priem_ali.a20linesquran;
  2.  
  3. import android.app.AlertDialog;
  4. import android.content.DialogInterface;
  5. import android.content.Intent;
  6. import android.graphics.Bitmap;
  7. import android.net.Uri;
  8. import android.support.v7.app.AppCompatActivity;
  9. import android.os.Bundle;
  10. import android.text.Editable;
  11. import android.text.InputType;
  12. import android.view.View;
  13. import android.widget.Button;
  14. import android.widget.EditText;
  15. import android.widget.Toast;
  16.  
  17. import java.io.File;
  18. import java.io.IOException;
  19.  
  20. public class Main_menu extends AppCompatActivity implements View.OnClickListener {
  21.  
  22. private Button button1;
  23. private Button button2;
  24. private Button button3;
  25. private Button button4;
  26. private Button button5;
  27.  
  28. @Override
  29. protected void onCreate(Bundle savedInstanceState) {
  30. super.onCreate(savedInstanceState);
  31. setContentView(R.layout.activity_main_menu);
  32.  
  33. button1 = (Button)findViewById( R.id.button1 );
  34. button2 = (Button)findViewById( R.id.button2 );
  35. button3 = (Button)findViewById( R.id.button3 );
  36. button4 = (Button)findViewById( R.id.button4 );
  37. button5 = (Button)findViewById( R.id.button5 );
  38.  
  39. button1.setOnClickListener( this );
  40. button2.setOnClickListener( this );
  41. button3.setOnClickListener( this );
  42. button4.setOnClickListener( this );
  43. button5.setOnClickListener( this );
  44.  
  45. }
  46.  
  47. @Override
  48. public void onClick(View v) {
  49.  
  50. if ( v == button1 ) {
  51. // Handle clicks for button1
  52. Intent i = new Intent(this,MainActivity.class);
  53. startActivity(i);
  54. } else if ( v == button2 ) {
  55.  
  56. save_in_extrenal_file db = new save_in_extrenal_file();
  57. db.datasaver("");
  58. } else if ( v == button3 ) {
  59. // Handle clicks for button3
  60. } else if ( v == button4 ) {
  61. // Handle clicks for button4
  62. } else if ( v == button5 ) {
  63. // Handle clicks for Go TO Page
  64.  
  65. try {
  66. // Handle clicks for button2
  67. AlertDialog.Builder alert = new AlertDialog.Builder(this);
  68. final EditText edittext = new EditText(this);
  69. alert.setMessage("Go To Page No#\n اذهب إلى رقم الصفحة");
  70. alert.setTitle("HOLY QURAN القرآن الكريم");
  71.  
  72. edittext.setInputType(InputType.TYPE_CLASS_NUMBER);
  73.  
  74. alert.setView(edittext);
  75.  
  76. alert.setPositiveButton("Search بحث", new DialogInterface.OnClickListener() {
  77. public void onClick(DialogInterface dialog, int whichButton) {
  78. //What ever you want to do with the value
  79. Editable YouEditTextValue = edittext.getText();
  80.  
  81. Toast.makeText(getApplicationContext(),"You Entered "+YouEditTextValue,Toast.LENGTH_LONG).show();
  82. }
  83. });
  84.  
  85. alert.setNegativeButton("Cancel إلغاء", new DialogInterface.OnClickListener() {
  86. public void onClick(DialogInterface dialog, int whichButton) {
  87. // what ever you want to do with No option.
  88. }
  89. });
  90.  
  91. alert.show();
  92. } catch (Exception e) {
  93. Toast.makeText(getApplicationContext(),e.toString(),Toast.LENGTH_LONG).show();
  94. e.printStackTrace();
  95. }
  96. }
  97. }
  98. }
Add Comment
Please, Sign In to add comment