Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.62 KB | None | 0 0
  1. package by.english.exams;
  2.  
  3. import android.app.Activity;
  4. import android.app.AlertDialog;
  5. import android.content.DialogInterface;
  6. import android.content.Intent;
  7. import android.os.Bundle;
  8. import android.text.Layout;
  9. import android.util.Log;
  10. import android.view.View;
  11. import android.webkit.WebView;
  12. import android.webkit.WebViewClient;
  13. import android.widget.Button;
  14. import android.widget.EditText;
  15. import android.widget.Toast;
  16.  
  17. import java.util.Scanner;
  18.  
  19. public class ActivityMain extends Activity {
  20. private String tag = "ActivityMain";
  21. WebView webView;
  22. EditText in;
  23. Button ok;
  24. String data;
  25.  
  26. @Override
  27. public void onCreate(final Bundle savedInstanceState) {
  28. super.onCreate(savedInstanceState);
  29. setContentView(R.layout.activity_main);
  30. Log.i(tag, "start");
  31.  
  32. setupClickHandlers();
  33. }
  34.  
  35. private void setupClickHandlers() {
  36. findViewById(R.id.btn_tickets).setOnClickListener(new View.OnClickListener() {
  37. @Override
  38. public void onClick(View v) {
  39. openTickets(
  40. new String[]{
  41. "ticket_1",
  42. "ticket_2",
  43. "ticket_3",
  44. "ticket_4",
  45. "ticket_5",
  46. "ticket_6",
  47. "ticket_7",
  48. "ticket_8",
  49. "ticket_9",
  50. "ticket_10",
  51. "ticket_11",
  52. "ticket_12",
  53. "ticket_13",
  54. "ticket_14",
  55. "ticket_15",
  56. "ticket_16",
  57. "ticket_17",
  58. "ticket_18",
  59. "ticket_19",
  60. "ticket_20",
  61. "ticket_21",
  62. "ticket_22",
  63. "ticket_23",
  64. "ticket_24",
  65. "ticket_25",
  66. },
  67. new String[]{
  68. "1. Family",
  69. "2. Family traditions",
  70. "3. Family relationship",
  71. "4. Friendship & relationship",
  72. "5. Education",
  73. "6. Studing at school",
  74. "7. School traditions",
  75. "8. Choosing a career",
  76. "9. Life in the city and country",
  77. "10. Different types of houses",
  78. "11. Belarussian national cuisine",
  79. "12. National cuisine of English country",
  80. "13. Shopping",
  81. "14. Leisure time",
  82. "15. Belarussian customs & traditions",
  83. "16. Customs & traditions an England",
  84. "17. Modern means of communication",
  85. "18. Healthy way of life",
  86. "19. Sport",
  87. "20. Fashion",
  88. "21. Travelling & tourism",
  89. "22. Environment",
  90. "23. Weather & climate",
  91. "24. The Republic of Belarus",
  92. "25. Great Britain",
  93. });
  94. }
  95. });
  96.  
  97. findViewById(R.id.btn_tickets_2).setOnClickListener(new View.OnClickListener() {
  98. @Override
  99. public void onClick(View v) {
  100. openTickets(
  101. new String[]{
  102. "ticket_audir_1",
  103. "ticket_audir_2",
  104. "ticket_audir_3",
  105. "ticket_audir_4",
  106. "ticket_audir_5",
  107. "ticket_audir_6",
  108. "ticket_audir_7",
  109. "ticket_audir_8",
  110. "ticket_audir_9",
  111. "ticket_audir_10",
  112. "ticket_audir_11",
  113. "ticket_audir_12",
  114. "ticket_audir_13",
  115. "ticket_audir_14",
  116. "ticket_audir_15",
  117. "ticket_audir_16",
  118. "ticket_audir_17",
  119. "ticket_audir_18",
  120. "ticket_audir_19",
  121. "ticket_audir_20",
  122. "ticket_audir_21",
  123. "ticket_audir_22",
  124. "ticket_audir_23",
  125. "ticket_audir_24",
  126. "ticket_audir_25",
  127. },
  128. new String[]{
  129. "Билет 1",
  130. "Билет 2",
  131. "Билет 3",
  132. "Билет 4",
  133. "Билет 5",
  134. "Билет 6",
  135. "Билет 7",
  136. "Билет 8",
  137. "Билет 9",
  138. "Билет 10",
  139. "Билет 11",
  140. "Билет 12",
  141. "Билет 13",
  142. "Билет 14",
  143. "Билет 15",
  144. "Билет 16",
  145. "Билет 17",
  146. "Билет 18",
  147. "Билет 19",
  148. "Билет 20",
  149. "Билет 21",
  150. "Билет 22",
  151. "Билет 23",
  152. "Билет 24",
  153. "Билет 25",
  154. });
  155. }
  156. });
  157.  
  158. findViewById(R.id.btn_tickets_3).setOnClickListener(new View.OnClickListener() {
  159. @Override
  160. public void onClick(View v) {
  161. openTickets(
  162. new String[]{
  163. "ticket_textwork_1",
  164. "ticket_textwork_2",
  165. "ticket_textwork_3",
  166. "ticket_textwork_4",
  167. "ticket_textwork_5",
  168. "ticket_textwork_6",
  169. "ticket_textwork_7",
  170. "ticket_textwork_8",
  171. "ticket_textwork_9",
  172. "ticket_textwork_10",
  173. "ticket_textwork_11",
  174. "ticket_textwork_12",
  175. "ticket_textwork_13",
  176. "ticket_textwork_14",
  177. "ticket_textwork_15",
  178. "ticket_textwork_16",
  179. "ticket_textwork_17",
  180. "ticket_textwork_18",
  181. "ticket_textwork_19",
  182. "ticket_textwork_20",
  183. "ticket_textwork_21",
  184. "ticket_textwork_22",
  185. "ticket_textwork_23",
  186. "ticket_textwork_24",
  187. "ticket_textwork_25",
  188. },
  189. new String[]{
  190. "1. CAN CHEATING BE STOPPED?",
  191. "2. Books in never ending motion",
  192. "3. Friendship in the modern world",
  193. "4. ACCORDING TO LAWS OF HOSPITALITY",
  194. "5. UNKNOWN ARTHUR CONAN DOYLE",
  195. "6. HAND MADE CHOCOLATES",
  196. "7. Mysterious Disappearance",
  197. "8. PABLO PICASSO",
  198. "9. Good news for chocolate lovers",
  199. "10. Do very clever children need help?",
  200. "11. FAMILY HISTORY",
  201. "12. BULLYING AGAIN?",
  202. "13. SHAKESPEARE’S PORTRAIT?",
  203. "14. Shopping in London",
  204. "15. University celebrates",
  205. "16. WORLD DIGITAL LIBRARY OPENS",
  206. "17. Special request to educational minister",
  207. "18. The most difficult language?",
  208. "19. Mobile phones",
  209. "20. How I got to the top",
  210. "21. Haloween",
  211. "22. Felt boots are feast for the eyes",
  212. "23. Village with history of a city",
  213. "Билет 24",
  214. "Билет 25",
  215. });
  216. }
  217. });
  218.  
  219. findViewById(R.id.btn_other).setOnClickListener(new View.OnClickListener() {
  220. @Override
  221. public void onClick(View v) {
  222. Toast.makeText(getApplicationContext(),
  223. "Здесь пока пусто!", Toast.LENGTH_LONG)
  224. .show();
  225. }
  226. });
  227. }
  228.  
  229. public void openTickets(String[] tickets, String[] names) {
  230. if (tickets.length != names.length) {
  231. throw new RuntimeException("tickets.length != names.length");
  232. }
  233. Intent intent = new Intent(ActivityMain.this, ActivityTickets.class);
  234. intent.putExtra(ActivityTickets.DATA_TICKETS_LIST, tickets);
  235. intent.putExtra(ActivityTickets.DATA_TICKETS_LIST_NAMES, names);
  236. startActivity(intent);
  237. }
  238.  
  239. public void onBackPressed() {
  240. // TODO Auto-generated method stub
  241. // super.onBackPressed();
  242. openQuitDialog();
  243. }
  244.  
  245. private void openQuitDialog() {
  246. AlertDialog.Builder quitDialog = new AlertDialog.Builder(
  247. ActivityMain.this);
  248. quitDialog.setTitle("Точно выйти?");
  249.  
  250. quitDialog.setPositiveButton("Выход", new DialogInterface.OnClickListener() {
  251. @Override
  252. public void onClick(DialogInterface dialog, int which) {
  253. finish();
  254. }
  255. });
  256.  
  257. quitDialog.setNegativeButton("Нет", new DialogInterface.OnClickListener() {
  258. @Override
  259. public void onClick(DialogInterface dialog, int which) {
  260. }
  261. });
  262.  
  263. quitDialog.show();
  264. }
  265.  
  266. public void imageButton(View view) {
  267. Toast toast = Toast.makeText(getApplicationContext(),
  268. "перестань нажимать",
  269. Toast.LENGTH_SHORT);
  270. // toast.setGravity(Gravity.CENTER, 0, 0);
  271. toast.show();
  272. }
  273.  
  274. public void settings(View view) {
  275. Intent intent = new Intent(ActivityMain.this, SettingsActivity.class);
  276. startActivity(intent);
  277. }
  278.  
  279. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement