Advertisement
Krizzdawg

Untitled

Dec 4th, 2017
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.18 KB | None | 0 0
  1. package com.example.programmingknowledge.simpleloginapp;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.ActionBarActivity;
  5. import android.os.Bundle;
  6. import android.view.Menu;
  7. import android.view.MenuItem;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.TextView;
  12. import android.widget.Toast;
  13.  
  14.  
  15. public class Login extends ActionBarActivity {
  16. private static EditText username;
  17. private static EditText password;
  18. private static TextView attempts;
  19. private static Button login_btn;
  20. int attempt_counter = 5;
  21. @Override
  22. protected void onCreate(Bundle savedInstanceState) {
  23. super.onCreate(savedInstanceState);
  24. setContentView(R.layout.activity_login);
  25. LoginButton();
  26. }
  27.  
  28. public void LoginButton() {
  29. username = (EditText)findViewById(R.id.editText_user);
  30. password = (EditText)findViewById(R.id.editText_password);
  31. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  32. login_btn = (Button)findViewById(R.id.button_login);
  33.  
  34. attempts.setText(Integer.toString(attempt_counter));
  35.  
  36. login_btn.setOnClickListener(
  37. new View.OnClickListener() {
  38. @Override
  39. public void onClick(View v) {
  40. if(username.getText().toString().equals("user") &&
  41. password.getText().toString().equals("pass") ) {
  42. Toast.makeText(Login.this,"User and Password is correct",
  43. Toast.LENGTH_SHORT).show();
  44. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  45. startActivity(intent);
  46. } else {
  47. Toast.makeText(Login.this,"User and Password is not correct",
  48. Toast.LENGTH_SHORT).show();
  49. attempt_counter--;
  50. attempts.setText(Integer.toString(attempt_counter));
  51. if(attempt_counter == 0){
  52. login_btn.setEnabled(false);
  53. }
  54. }
  55.  
  56. }
  57. }
  58. );
  59. }
  60.  
  61. @Override
  62. public boolean onCreateOptionsMenu(Menu menu) {
  63. // Inflate the menu; this adds items to the action bar if it is present.
  64. getMenuInflater().inflate(R.menu.menu_login, menu);
  65. return true;
  66. }
  67.  
  68. @Override
  69. public boolean onOptionsItemSelected(MenuItem item) {
  70. // Handle action bar item clicks here. The action bar will
  71. // automatically handle clicks on the Home/Up button, so long
  72. // as you specify a parent activity in AndroidManifest.xml.
  73. int id = item.getItemId();
  74.  
  75. //noinspection SimplifiableIfStatement
  76. if (id == R.id.action_settings) {
  77. return true;
  78. }
  79.  
  80. return super.onOptionsItemSelected(item);
  81. }
  82. }package com.example.programmingknowledge.simpleloginapp;
  83.  
  84. import android.content.Intent;
  85. import android.support.v7.app.ActionBarActivity;
  86. import android.os.Bundle;
  87. import android.view.Menu;
  88. import android.view.MenuItem;
  89. import android.view.View;
  90. import android.widget.Button;
  91. import android.widget.EditText;
  92. import android.widget.TextView;
  93. import android.widget.Toast;
  94.  
  95.  
  96. public class Login extends ActionBarActivity {
  97. private static EditText username;
  98. private static EditText password;
  99. private static TextView attempts;
  100. private static Button login_btn;
  101. int attempt_counter = 5;
  102. @Override
  103. protected void onCreate(Bundle savedInstanceState) {
  104. super.onCreate(savedInstanceState);
  105. setContentView(R.layout.activity_login);
  106. LoginButton();
  107. }
  108.  
  109. public void LoginButton() {
  110. username = (EditText)findViewById(R.id.editText_user);
  111. password = (EditText)findViewById(R.id.editText_password);
  112. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  113. login_btn = (Button)findViewById(R.id.button_login);
  114.  
  115. attempts.setText(Integer.toString(attempt_counter));
  116.  
  117. login_btn.setOnClickListener(
  118. new View.OnClickListener() {
  119. @Override
  120. public void onClick(View v) {
  121. if(username.getText().toString().equals("user") &&
  122. password.getText().toString().equals("pass") ) {
  123. Toast.makeText(Login.this,"User and Password is correct",
  124. Toast.LENGTH_SHORT).show();
  125. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  126. startActivity(intent);
  127. } else {
  128. Toast.makeText(Login.this,"User and Password is not correct",
  129. Toast.LENGTH_SHORT).show();
  130. attempt_counter--;
  131. attempts.setText(Integer.toString(attempt_counter));
  132. if(attempt_counter == 0){
  133. login_btn.setEnabled(false);
  134. }
  135. }
  136.  
  137. }
  138. }
  139. );
  140. }
  141.  
  142. @Override
  143. public boolean onCreateOptionsMenu(Menu menu) {
  144. // Inflate the menu; this adds items to the action bar if it is present.
  145. getMenuInflater().inflate(R.menu.menu_login, menu);
  146. return true;
  147. }
  148.  
  149. @Override
  150. public boolean onOptionsItemSelected(MenuItem item) {
  151. // Handle action bar item clicks here. The action bar will
  152. // automatically handle clicks on the Home/Up button, so long
  153. // as you specify a parent activity in AndroidManifest.xml.
  154. int id = item.getItemId();
  155.  
  156. //noinspection SimplifiableIfStatement
  157. if (id == R.id.action_settings) {
  158. return true;
  159. }
  160.  
  161. return super.onOptionsItemSelected(item);
  162. }
  163. }package com.example.programmingknowledge.simpleloginapp;
  164.  
  165. import android.content.Intent;
  166. import android.support.v7.app.ActionBarActivity;
  167. import android.os.Bundle;
  168. import android.view.Menu;
  169. import android.view.MenuItem;
  170. import android.view.View;
  171. import android.widget.Button;
  172. import android.widget.EditText;
  173. import android.widget.TextView;
  174. import android.widget.Toast;
  175.  
  176.  
  177. public class Login extends ActionBarActivity {
  178. private static EditText username;
  179. private static EditText password;
  180. private static TextView attempts;
  181. private static Button login_btn;
  182. int attempt_counter = 5;
  183. @Override
  184. protected void onCreate(Bundle savedInstanceState) {
  185. super.onCreate(savedInstanceState);
  186. setContentView(R.layout.activity_login);
  187. LoginButton();
  188. }
  189.  
  190. public void LoginButton() {
  191. username = (EditText)findViewById(R.id.editText_user);
  192. password = (EditText)findViewById(R.id.editText_password);
  193. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  194. login_btn = (Button)findViewById(R.id.button_login);
  195.  
  196. attempts.setText(Integer.toString(attempt_counter));
  197.  
  198. login_btn.setOnClickListener(
  199. new View.OnClickListener() {
  200. @Override
  201. public void onClick(View v) {
  202. if(username.getText().toString().equals("user") &&
  203. password.getText().toString().equals("pass") ) {
  204. Toast.makeText(Login.this,"User and Password is correct",
  205. Toast.LENGTH_SHORT).show();
  206. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  207. startActivity(intent);
  208. } else {
  209. Toast.makeText(Login.this,"User and Password is not correct",
  210. Toast.LENGTH_SHORT).show();
  211. attempt_counter--;
  212. attempts.setText(Integer.toString(attempt_counter));
  213. if(attempt_counter == 0){
  214. login_btn.setEnabled(false);
  215. }
  216. }
  217.  
  218. }
  219. }
  220. );
  221. }
  222.  
  223. @Override
  224. public boolean onCreateOptionsMenu(Menu menu) {
  225. // Inflate the menu; this adds items to the action bar if it is present.
  226. getMenuInflater().inflate(R.menu.menu_login, menu);
  227. return true;
  228. }
  229.  
  230. @Override
  231. public boolean onOptionsItemSelected(MenuItem item) {
  232. // Handle action bar item clicks here. The action bar will
  233. // automatically handle clicks on the Home/Up button, so long
  234. // as you specify a parent activity in AndroidManifest.xml.
  235. int id = item.getItemId();
  236.  
  237. //noinspection SimplifiableIfStatement
  238. if (id == R.id.action_settings) {
  239. return true;
  240. }
  241.  
  242. return super.onOptionsItemSelected(item);
  243. }
  244. }package com.example.programmingknowledge.simpleloginapp;
  245.  
  246. import android.content.Intent;
  247. import android.support.v7.app.ActionBarActivity;
  248. import android.os.Bundle;
  249. import android.view.Menu;
  250. import android.view.MenuItem;
  251. import android.view.View;
  252. import android.widget.Button;
  253. import android.widget.EditText;
  254. import android.widget.TextView;
  255. import android.widget.Toast;
  256.  
  257.  
  258. public class Login extends ActionBarActivity {
  259. private static EditText username;
  260. private static EditText password;
  261. private static TextView attempts;
  262. private static Button login_btn;
  263. int attempt_counter = 5;
  264. @Override
  265. protected void onCreate(Bundle savedInstanceState) {
  266. super.onCreate(savedInstanceState);
  267. setContentView(R.layout.activity_login);
  268. LoginButton();
  269. }
  270.  
  271. public void LoginButton() {
  272. username = (EditText)findViewById(R.id.editText_user);
  273. password = (EditText)findViewById(R.id.editText_password);
  274. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  275. login_btn = (Button)findViewById(R.id.button_login);
  276.  
  277. attempts.setText(Integer.toString(attempt_counter));
  278.  
  279. login_btn.setOnClickListener(
  280. new View.OnClickListener() {
  281. @Override
  282. public void onClick(View v) {
  283. if(username.getText().toString().equals("user") &&
  284. password.getText().toString().equals("pass") ) {
  285. Toast.makeText(Login.this,"User and Password is correct",
  286. Toast.LENGTH_SHORT).show();
  287. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  288. startActivity(intent);
  289. } else {
  290. Toast.makeText(Login.this,"User and Password is not correct",
  291. Toast.LENGTH_SHORT).show();
  292. attempt_counter--;
  293. attempts.setText(Integer.toString(attempt_counter));
  294. if(attempt_counter == 0){
  295. login_btn.setEnabled(false);
  296. }
  297. }
  298.  
  299. }
  300. }
  301. );
  302. }
  303.  
  304. @Override
  305. public boolean onCreateOptionsMenu(Menu menu) {
  306. // Inflate the menu; this adds items to the action bar if it is present.
  307. getMenuInflater().inflate(R.menu.menu_login, menu);
  308. return true;
  309. }
  310.  
  311. @Override
  312. public boolean onOptionsItemSelected(MenuItem item) {
  313. // Handle action bar item clicks here. The action bar will
  314. // automatically handle clicks on the Home/Up button, so long
  315. // as you specify a parent activity in AndroidManifest.xml.
  316. int id = item.getItemId();
  317.  
  318. //noinspection SimplifiableIfStatement
  319. if (id == R.id.action_settings) {
  320. return true;
  321. }
  322.  
  323. return super.onOptionsItemSelected(item);
  324. }
  325. }package com.example.programmingknowledge.simpleloginapp;
  326.  
  327. import android.content.Intent;
  328. import android.support.v7.app.ActionBarActivity;
  329. import android.os.Bundle;
  330. import android.view.Menu;
  331. import android.view.MenuItem;
  332. import android.view.View;
  333. import android.widget.Button;
  334. import android.widget.EditText;
  335. import android.widget.TextView;
  336. import android.widget.Toast;
  337.  
  338.  
  339. public class Login extends ActionBarActivity {
  340. private static EditText username;
  341. private static EditText password;
  342. private static TextView attempts;
  343. private static Button login_btn;
  344. int attempt_counter = 5;
  345. @Override
  346. protected void onCreate(Bundle savedInstanceState) {
  347. super.onCreate(savedInstanceState);
  348. setContentView(R.layout.activity_login);
  349. LoginButton();
  350. }
  351.  
  352. public void LoginButton() {
  353. username = (EditText)findViewById(R.id.editText_user);
  354. password = (EditText)findViewById(R.id.editText_password);
  355. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  356. login_btn = (Button)findViewById(R.id.button_login);
  357.  
  358. attempts.setText(Integer.toString(attempt_counter));
  359.  
  360. login_btn.setOnClickListener(
  361. new View.OnClickListener() {
  362. @Override
  363. public void onClick(View v) {
  364. if(username.getText().toString().equals("user") &&
  365. password.getText().toString().equals("pass") ) {
  366. Toast.makeText(Login.this,"User and Password is correct",
  367. Toast.LENGTH_SHORT).show();
  368. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  369. startActivity(intent);
  370. } else {
  371. Toast.makeText(Login.this,"User and Password is not correct",
  372. Toast.LENGTH_SHORT).show();
  373. attempt_counter--;
  374. attempts.setText(Integer.toString(attempt_counter));
  375. if(attempt_counter == 0){
  376. login_btn.setEnabled(false);
  377. }
  378. }
  379.  
  380. }
  381. }
  382. );
  383. }
  384.  
  385. @Override
  386. public boolean onCreateOptionsMenu(Menu menu) {
  387. // Inflate the menu; this adds items to the action bar if it is present.
  388. getMenuInflater().inflate(R.menu.menu_login, menu);
  389. return true;
  390. }
  391.  
  392. @Override
  393. public boolean onOptionsItemSelected(MenuItem item) {
  394. // Handle action bar item clicks here. The action bar will
  395. // automatically handle clicks on the Home/Up button, so long
  396. // as you specify a parent activity in AndroidManifest.xml.
  397. int id = item.getItemId();
  398.  
  399. //noinspection SimplifiableIfStatement
  400. if (id == R.id.action_settings) {
  401. return true;
  402. }
  403.  
  404. return super.onOptionsItemSelected(item);
  405. }
  406. }package com.example.programmingknowledge.simpleloginapp;
  407.  
  408. import android.content.Intent;
  409. import android.support.v7.app.ActionBarActivity;
  410. import android.os.Bundle;
  411. import android.view.Menu;
  412. import android.view.MenuItem;
  413. import android.view.View;
  414. import android.widget.Button;
  415. import android.widget.EditText;
  416. import android.widget.TextView;
  417. import android.widget.Toast;
  418.  
  419.  
  420. public class Login extends ActionBarActivity {
  421. private static EditText username;
  422. private static EditText password;
  423. private static TextView attempts;
  424. private static Button login_btn;
  425. int attempt_counter = 5;
  426. @Override
  427. protected void onCreate(Bundle savedInstanceState) {
  428. super.onCreate(savedInstanceState);
  429. setContentView(R.layout.activity_login);
  430. LoginButton();
  431. }
  432.  
  433. public void LoginButton() {
  434. username = (EditText)findViewById(R.id.editText_user);
  435. password = (EditText)findViewById(R.id.editText_password);
  436. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  437. login_btn = (Button)findViewById(R.id.button_login);
  438.  
  439. attempts.setText(Integer.toString(attempt_counter));
  440.  
  441. login_btn.setOnClickListener(
  442. new View.OnClickListener() {
  443. @Override
  444. public void onClick(View v) {
  445. if(username.getText().toString().equals("user") &&
  446. password.getText().toString().equals("pass") ) {
  447. Toast.makeText(Login.this,"User and Password is correct",
  448. Toast.LENGTH_SHORT).show();
  449. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  450. startActivity(intent);
  451. } else {
  452. Toast.makeText(Login.this,"User and Password is not correct",
  453. Toast.LENGTH_SHORT).show();
  454. attempt_counter--;
  455. attempts.setText(Integer.toString(attempt_counter));
  456. if(attempt_counter == 0){
  457. login_btn.setEnabled(false);
  458. }
  459. }
  460.  
  461. }
  462. }
  463. );
  464. }
  465.  
  466. @Override
  467. public boolean onCreateOptionsMenu(Menu menu) {
  468. // Inflate the menu; this adds items to the action bar if it is present.
  469. getMenuInflater().inflate(R.menu.menu_login, menu);
  470. return true;
  471. }
  472.  
  473. @Override
  474. public boolean onOptionsItemSelected(MenuItem item) {
  475. // Handle action bar item clicks here. The action bar will
  476. // automatically handle clicks on the Home/Up button, so long
  477. // as you specify a parent activity in AndroidManifest.xml.
  478. int id = item.getItemId();
  479.  
  480. //noinspection SimplifiableIfStatement
  481. if (id == R.id.action_settings) {
  482. return true;
  483. }
  484.  
  485. return super.onOptionsItemSelected(item);
  486. }
  487. }package com.example.programmingknowledge.simpleloginapp;
  488.  
  489. import android.content.Intent;
  490. import android.support.v7.app.ActionBarActivity;
  491. import android.os.Bundle;
  492. import android.view.Menu;
  493. import android.view.MenuItem;
  494. import android.view.View;
  495. import android.widget.Button;
  496. import android.widget.EditText;
  497. import android.widget.TextView;
  498. import android.widget.Toast;
  499.  
  500.  
  501. public class Login extends ActionBarActivity {
  502. private static EditText username;
  503. private static EditText password;
  504. private static TextView attempts;
  505. private static Button login_btn;
  506. int attempt_counter = 5;
  507. @Override
  508. protected void onCreate(Bundle savedInstanceState) {
  509. super.onCreate(savedInstanceState);
  510. setContentView(R.layout.activity_login);
  511. LoginButton();
  512. }
  513.  
  514. public void LoginButton() {
  515. username = (EditText)findViewById(R.id.editText_user);
  516. password = (EditText)findViewById(R.id.editText_password);
  517. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  518. login_btn = (Button)findViewById(R.id.button_login);
  519.  
  520. attempts.setText(Integer.toString(attempt_counter));
  521.  
  522. login_btn.setOnClickListener(
  523. new View.OnClickListener() {
  524. @Override
  525. public void onClick(View v) {
  526. if(username.getText().toString().equals("user") &&
  527. password.getText().toString().equals("pass") ) {
  528. Toast.makeText(Login.this,"User and Password is correct",
  529. Toast.LENGTH_SHORT).show();
  530. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  531. startActivity(intent);
  532. } else {
  533. Toast.makeText(Login.this,"User and Password is not correct",
  534. Toast.LENGTH_SHORT).show();
  535. attempt_counter--;
  536. attempts.setText(Integer.toString(attempt_counter));
  537. if(attempt_counter == 0){
  538. login_btn.setEnabled(false);
  539. }
  540. }
  541.  
  542. }
  543. }
  544. );
  545. }
  546.  
  547. @Override
  548. public boolean onCreateOptionsMenu(Menu menu) {
  549. // Inflate the menu; this adds items to the action bar if it is present.
  550. getMenuInflater().inflate(R.menu.menu_login, menu);
  551. return true;
  552. }
  553.  
  554. @Override
  555. public boolean onOptionsItemSelected(MenuItem item) {
  556. // Handle action bar item clicks here. The action bar will
  557. // automatically handle clicks on the Home/Up button, so long
  558. // as you specify a parent activity in AndroidManifest.xml.
  559. int id = item.getItemId();
  560.  
  561. //noinspection SimplifiableIfStatement
  562. if (id == R.id.action_settings) {
  563. return true;
  564. }
  565.  
  566. return super.onOptionsItemSelected(item);
  567. }
  568. }fvpackage com.example.programmingknowledge.simpleloginapp;
  569.  
  570. import android.content.Intent;
  571. import android.support.v7.app.ActionBarActivity;
  572. import android.os.Bundle;
  573. import android.view.Menu;
  574. import android.view.MenuItem;
  575. import android.view.View;
  576. import android.widget.Button;
  577. import android.widget.EditText;
  578. import android.widget.TextView;
  579. import android.widget.Toast;
  580.  
  581.  
  582. public class Login extends ActionBarActivity {
  583. private static EditText username;
  584. private static EditText password;
  585. private static TextView attempts;
  586. private static Button login_btn;
  587. int attempt_counter = 5;
  588. @Override
  589. protected void onCreate(Bundle savedInstanceState) {
  590. super.onCreate(savedInstanceState);
  591. setContentView(R.layout.activity_login);
  592. LoginButton();
  593. }
  594.  
  595. public void LoginButton() {
  596. username = (EditText)findViewById(R.id.editText_user);
  597. password = (EditText)findViewById(R.id.editText_password);
  598. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  599. login_btn = (Button)findViewById(R.id.button_login);
  600.  
  601. attempts.setText(Integer.toString(attempt_counter));
  602.  
  603. login_btn.setOnClickListener(
  604. new View.OnClickListener() {
  605. @Override
  606. public void onClick(View v) {
  607. if(username.getText().toString().equals("user") &&
  608. password.getText().toString().equals("pass") ) {
  609. Toast.makeText(Login.this,"User and Password is correct",
  610. Toast.LENGTH_SHORT).show();
  611. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  612. startActivity(intent);
  613. } else {
  614. Toast.makeText(Login.this,"User and Password is not correct",
  615. Toast.LENGTH_SHORT).show();
  616. attempt_counter--;
  617. attempts.setText(Integer.toString(attempt_counter));
  618. if(attempt_counter == 0){
  619. login_btn.setEnabled(false);
  620. }
  621. }
  622.  
  623. }
  624. }
  625. );
  626. }
  627.  
  628. @Override
  629. public boolean onCreateOptionsMenu(Menu menu) {
  630. // Inflate the menu; this adds items to the action bar if it is present.
  631. getMenuInflater().inflate(R.menu.menu_login, menu);
  632. return true;
  633. }
  634.  
  635. @Override
  636. public boolean onOptionsItemSelected(MenuItem item) {
  637. // Handle action bar item clicks here. The action bar will
  638. // automatically handle clicks on the Home/Up button, so long
  639. // as you specify a parent activity in AndroidManifest.xml.
  640. int id = item.getItemId();
  641.  
  642. //noinspection SimplifiableIfStatement
  643. if (id == R.id.action_settings) {
  644. return true;
  645. }
  646.  
  647. return super.onOptionsItemSelected(item);
  648. }
  649. }package com.example.programmingknowledge.simpleloginapp;
  650.  
  651. import android.content.Intent;
  652. import android.support.v7.app.ActionBarActivity;
  653. import android.os.Bundle;
  654. import android.view.Menu;
  655. import android.view.MenuItem;
  656. import android.view.View;
  657. import android.widget.Button;
  658. import android.widget.EditText;
  659. import android.widget.TextView;
  660. import android.widget.Toast;
  661.  
  662.  
  663. public class Login extends ActionBarActivity {
  664. private static EditText username;
  665. private static EditText password;
  666. private static TextView attempts;
  667. private static Button login_btn;
  668. int attempt_counter = 5;
  669. @Override
  670. protected void onCreate(Bundle savedInstanceState) {
  671. super.onCreate(savedInstanceState);
  672. setContentView(R.layout.activity_login);
  673. LoginButton();
  674. }
  675.  
  676. public void LoginButton() {
  677. username = (EditText)findViewById(R.id.editText_user);
  678. password = (EditText)findViewById(R.id.editText_password);
  679. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  680. login_btn = (Button)findViewById(R.id.button_login);
  681.  
  682. attempts.setText(Integer.toString(attempt_counter));
  683.  
  684. login_btn.setOnClickListener(
  685. new View.OnClickListener() {
  686. @Override
  687. public void onClick(View v) {
  688. if(username.getText().toString().equals("user") &&
  689. password.getText().toString().equals("pass") ) {
  690. Toast.makeText(Login.this,"User and Password is correct",
  691. Toast.LENGTH_SHORT).show();
  692. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  693. startActivity(intent);
  694. } else {
  695. Toast.makeText(Login.this,"User and Password is not correct",
  696. Toast.LENGTH_SHORT).show();
  697. attempt_counter--;
  698. attempts.setText(Integer.toString(attempt_counter));
  699. if(attempt_counter == 0){
  700. login_btn.setEnabled(false);
  701. }
  702. }
  703.  
  704. }
  705. }
  706. );
  707. }
  708.  
  709. @Override
  710. public boolean onCreateOptionsMenu(Menu menu) {
  711. // Inflate the menu; this adds items to the action bar if it is present.
  712. getMenuInflater().inflate(R.menu.menu_login, menu);
  713. return true;
  714. }
  715.  
  716. @Override
  717. public boolean onOptionsItemSelected(MenuItem item) {
  718. // Handle action bar item clicks here. The action bar will
  719. // automatically handle clicks on the Home/Up button, so long
  720. // as you specify a parent activity in AndroidManifest.xml.
  721. int id = item.getItemId();
  722.  
  723. //noinspection SimplifiableIfStatement
  724. if (id == R.id.action_settings) {
  725. return true;
  726. }
  727.  
  728. return super.onOptionsItemSelected(item);
  729. }
  730. }package com.example.programmingknowledge.simpleloginapp;
  731.  
  732. import android.content.Intent;
  733. import android.support.v7.app.ActionBarActivity;
  734. import android.os.Bundle;
  735. import android.view.Menu;
  736. import android.view.MenuItem;
  737. import android.view.View;
  738. import android.widget.Button;
  739. import android.widget.EditText;
  740. import android.widget.TextView;
  741. import android.widget.Toast;
  742.  
  743.  
  744. public class Login extends ActionBarActivity {
  745. private static EditText username;
  746. private static EditText password;
  747. private static TextView attempts;
  748. private static Button login_btn;
  749. int attempt_counter = 5;
  750. @Override
  751. protected void onCreate(Bundle savedInstanceState) {
  752. super.onCreate(savedInstanceState);
  753. setContentView(R.layout.activity_login);
  754. LoginButton();
  755. }
  756.  
  757. public void LoginButton() {
  758. username = (EditText)findViewById(R.id.editText_user);
  759. password = (EditText)findViewById(R.id.editText_password);
  760. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  761. login_btn = (Button)findViewById(R.id.button_login);
  762.  
  763. attempts.setText(Integer.toString(attempt_counter));
  764.  
  765. login_btn.setOnClickListener(
  766. new View.OnClickListener() {
  767. @Override
  768. public void onClick(View v) {
  769. if(username.getText().toString().equals("user") &&
  770. password.getText().toString().equals("pass") ) {
  771. Toast.makeText(Login.this,"User and Password is correct",
  772. Toast.LENGTH_SHORT).show();
  773. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  774. startActivity(intent);
  775. } else {
  776. Toast.makeText(Login.this,"User and Password is not correct",
  777. Toast.LENGTH_SHORT).show();
  778. attempt_counter--;
  779. attempts.setText(Integer.toString(attempt_counter));
  780. if(attempt_counter == 0){
  781. login_btn.setEnabled(false);
  782. }
  783. }
  784.  
  785. }
  786. }
  787. );
  788. }
  789.  
  790. @Override
  791. public boolean onCreateOptionsMenu(Menu menu) {
  792. // Inflate the menu; this adds items to the action bar if it is present.
  793. getMenuInflater().inflate(R.menu.menu_login, menu);
  794. return true;
  795. }
  796.  
  797. @Override
  798. public boolean onOptionsItemSelected(MenuItem item) {
  799. // Handle action bar item clicks here. The action bar will
  800. // automatically handle clicks on the Home/Up button, so long
  801. // as you specify a parent activity in AndroidManifest.xml.
  802. int id = item.getItemId();
  803.  
  804. //noinspection SimplifiableIfStatement
  805. if (id == R.id.action_settings) {
  806. return true;
  807. }
  808.  
  809. return super.onOptionsItemSelected(item);
  810. }
  811. }package com.example.programmingknowledge.simpleloginapp;
  812.  
  813. import android.content.Intent;
  814. import android.support.v7.app.ActionBarActivity;
  815. import android.os.Bundle;
  816. import android.view.Menu;
  817. import android.view.MenuItem;
  818. import android.view.View;
  819. import android.widget.Button;
  820. import android.widget.EditText;
  821. import android.widget.TextView;
  822. import android.widget.Toast;
  823.  
  824.  
  825. public class Login extends ActionBarActivity {
  826. private static EditText username;
  827. private static EditText password;
  828. private static TextView attempts;
  829. private static Button login_btn;
  830. int attempt_counter = 5;
  831. @Override
  832. protected void onCreate(Bundle savedInstanceState) {
  833. super.onCreate(savedInstanceState);
  834. setContentView(R.layout.activity_login);
  835. LoginButton();
  836. }
  837.  
  838. public void LoginButton() {
  839. username = (EditText)findViewById(R.id.editText_user);
  840. password = (EditText)findViewById(R.id.editText_password);
  841. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  842. login_btn = (Button)findViewById(R.id.button_login);
  843.  
  844. attempts.setText(Integer.toString(attempt_counter));
  845.  
  846. login_btn.setOnClickListener(
  847. new View.OnClickListener() {
  848. @Override
  849. public void onClick(View v) {
  850. if(username.getText().toString().equals("user") &&
  851. password.getText().toString().equals("pass") ) {
  852. Toast.makeText(Login.this,"User and Password is correct",
  853. Toast.LENGTH_SHORT).show();
  854. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  855. startActivity(intent);
  856. } else {
  857. Toast.makeText(Login.this,"User and Password is not correct",
  858. Toast.LENGTH_SHORT).show();
  859. attempt_counter--;
  860. attempts.setText(Integer.toString(attempt_counter));
  861. if(attempt_counter == 0){
  862. login_btn.setEnabled(false);
  863. }
  864. }
  865.  
  866. }
  867. }
  868. );
  869. }
  870.  
  871. @Override
  872. public boolean onCreateOptionsMenu(Menu menu) {
  873. // Inflate the menu; this adds items to the action bar if it is present.
  874. getMenuInflater().inflate(R.menu.menu_login, menu);
  875. return true;
  876. }
  877.  
  878. @Override
  879. public boolean onOptionsItemSelected(MenuItem item) {
  880. // Handle action bar item clicks here. The action bar will
  881. // automatically handle clicks on the Home/Up button, so long
  882. // as you specify a parent activity in AndroidManifest.xml.
  883. int id = item.getItemId();
  884.  
  885. //noinspection SimplifiableIfStatement
  886. if (id == R.id.action_settings) {
  887. return true;
  888. }
  889.  
  890. return super.onOptionsItemSelected(item);
  891. }
  892. }package com.example.programmingknowledge.simpleloginapp;
  893.  
  894. import android.content.Intent;
  895. import android.support.v7.app.ActionBarActivity;
  896. import android.os.Bundle;
  897. import android.view.Menu;
  898. import android.view.MenuItem;
  899. import android.view.View;
  900. import android.widget.Button;
  901. import android.widget.EditText;
  902. import android.widget.TextView;
  903. import android.widget.Toast;
  904.  
  905.  
  906. public class Login extends ActionBarActivity {
  907. private static EditText username;
  908. private static EditText password;
  909. private static TextView attempts;
  910. private static Button login_btn;
  911. int attempt_counter = 5;
  912. @Override
  913. protected void onCreate(Bundle savedInstanceState) {
  914. super.onCreate(savedInstanceState);
  915. setContentView(R.layout.activity_login);
  916. LoginButton();
  917. }
  918.  
  919. public void LoginButton() {
  920. username = (EditText)findViewById(R.id.editText_user);
  921. password = (EditText)findViewById(R.id.editText_password);
  922. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  923. login_btn = (Button)findViewById(R.id.button_login);
  924.  
  925. attempts.setText(Integer.toString(attempt_counter));
  926.  
  927. login_btn.setOnClickListener(
  928. new View.OnClickListener() {
  929. @Override
  930. public void onClick(View v) {
  931. if(username.getText().toString().equals("user") &&
  932. password.getText().toString().equals("pass") ) {
  933. Toast.makeText(Login.this,"User and Password is correct",
  934. Toast.LENGTH_SHORT).show();
  935. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  936. startActivity(intent);
  937. } else {
  938. Toast.makeText(Login.this,"User and Password is not correct",
  939. Toast.LENGTH_SHORT).show();
  940. attempt_counter--;
  941. attempts.setText(Integer.toString(attempt_counter));
  942. if(attempt_counter == 0){
  943. login_btn.setEnabled(false);
  944. }
  945. }
  946.  
  947. }
  948. }
  949. );
  950. }
  951.  
  952. @Override
  953. public boolean onCreateOptionsMenu(Menu menu) {
  954. // Inflate the menu; this adds items to the action bar if it is present.
  955. getMenuInflater().inflate(R.menu.menu_login, menu);
  956. return true;
  957. }
  958.  
  959. @Override
  960. public boolean onOptionsItemSelected(MenuItem item) {
  961. // Handle action bar item clicks here. The action bar will
  962. // automatically handle clicks on the Home/Up button, so long
  963. // as you specify a parent activity in AndroidManifest.xml.
  964. int id = item.getItemId();
  965.  
  966. //noinspection SimplifiableIfStatement
  967. if (id == R.id.action_settings) {
  968. return true;
  969. }
  970.  
  971. return super.onOptionsItemSelected(item);
  972. }
  973. }package com.example.programmingknowledge.simpleloginapp;
  974.  
  975. import android.content.Intent;
  976. import android.support.v7.app.ActionBarActivity;
  977. import android.os.Bundle;
  978. import android.view.Menu;
  979. import android.view.MenuItem;
  980. import android.view.View;
  981. import android.widget.Button;
  982. import android.widget.EditText;
  983. import android.widget.TextView;
  984. import android.widget.Toast;
  985.  
  986.  
  987. public class Login extends ActionBarActivity {
  988. private static EditText username;
  989. private static EditText password;
  990. private static TextView attempts;
  991. private static Button login_btn;
  992. int attempt_counter = 5;
  993. @Override
  994. protected void onCreate(Bundle savedInstanceState) {
  995. super.onCreate(savedInstanceState);
  996. setContentView(R.layout.activity_login);
  997. LoginButton();
  998. }
  999.  
  1000. public void LoginButton() {
  1001. username = (EditText)findViewById(R.id.editText_user);
  1002. password = (EditText)findViewById(R.id.editText_password);
  1003. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1004. login_btn = (Button)findViewById(R.id.button_login);
  1005.  
  1006. attempts.setText(Integer.toString(attempt_counter));
  1007.  
  1008. login_btn.setOnClickListener(
  1009. new View.OnClickListener() {
  1010. @Override
  1011. public void onClick(View v) {
  1012. if(username.getText().toString().equals("user") &&
  1013. password.getText().toString().equals("pass") ) {
  1014. Toast.makeText(Login.this,"User and Password is correct",
  1015. Toast.LENGTH_SHORT).show();
  1016. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1017. startActivity(intent);
  1018. } else {
  1019. Toast.makeText(Login.this,"User and Password is not correct",
  1020. Toast.LENGTH_SHORT).show();
  1021. attempt_counter--;
  1022. attempts.setText(Integer.toString(attempt_counter));
  1023. if(attempt_counter == 0){
  1024. login_btn.setEnabled(false);
  1025. }
  1026. }
  1027.  
  1028. }
  1029. }
  1030. );
  1031. }
  1032.  
  1033. @Override
  1034. public boolean onCreateOptionsMenu(Menu menu) {
  1035. // Inflate the menu; this adds items to the action bar if it is present.
  1036. getMenuInflater().inflate(R.menu.menu_login, menu);
  1037. return true;
  1038. }
  1039.  
  1040. @Override
  1041. public boolean onOptionsItemSelected(MenuItem item) {
  1042. // Handle action bar item clicks here. The action bar will
  1043. // automatically handle clicks on the Home/Up button, so long
  1044. // as you specify a parent activity in AndroidManifest.xml.
  1045. int id = item.getItemId();
  1046.  
  1047. //noinspection SimplifiableIfStatement
  1048. if (id == R.id.action_settings) {
  1049. return true;
  1050. }
  1051.  
  1052. return super.onOptionsItemSelected(item);
  1053. }
  1054. }package com.example.programmingknowledge.simpleloginapp;
  1055.  
  1056. import android.content.Intent;
  1057. import android.support.v7.app.ActionBarActivity;
  1058. import android.os.Bundle;
  1059. import android.view.Menu;
  1060. import android.view.MenuItem;
  1061. import android.view.View;
  1062. import android.widget.Button;
  1063. import android.widget.EditText;
  1064. import android.widget.TextView;
  1065. import android.widget.Toast;
  1066.  
  1067.  
  1068. public class Login extends ActionBarActivity {
  1069. private static EditText username;
  1070. private static EditText password;
  1071. private static TextView attempts;
  1072. private static Button login_btn;
  1073. int attempt_counter = 5;
  1074. @Override
  1075. protected void onCreate(Bundle savedInstanceState) {
  1076. super.onCreate(savedInstanceState);
  1077. setContentView(R.layout.activity_login);
  1078. LoginButton();
  1079. }
  1080.  
  1081. public void LoginButton() {
  1082. username = (EditText)findViewById(R.id.editText_user);
  1083. password = (EditText)findViewById(R.id.editText_password);
  1084. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1085. login_btn = (Button)findViewById(R.id.button_login);
  1086.  
  1087. attempts.setText(Integer.toString(attempt_counter));
  1088.  
  1089. login_btn.setOnClickListener(
  1090. new View.OnClickListener() {
  1091. @Override
  1092. public void onClick(View v) {
  1093. if(username.getText().toString().equals("user") &&
  1094. password.getText().toString().equals("pass") ) {
  1095. Toast.makeText(Login.this,"User and Password is correct",
  1096. Toast.LENGTH_SHORT).show();
  1097. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1098. startActivity(intent);
  1099. } else {
  1100. Toast.makeText(Login.this,"User and Password is not correct",
  1101. Toast.LENGTH_SHORT).show();
  1102. attempt_counter--;
  1103. attempts.setText(Integer.toString(attempt_counter));
  1104. if(attempt_counter == 0){
  1105. login_btn.setEnabled(false);
  1106. }
  1107. }
  1108.  
  1109. }
  1110. }
  1111. );
  1112. }
  1113.  
  1114. @Override
  1115. public boolean onCreateOptionsMenu(Menu menu) {
  1116. // Inflate the menu; this adds items to the action bar if it is present.
  1117. getMenuInflater().inflate(R.menu.menu_login, menu);
  1118. return true;
  1119. }
  1120.  
  1121. @Override
  1122. public boolean onOptionsItemSelected(MenuItem item) {
  1123. // Handle action bar item clicks here. The action bar will
  1124. // automatically handle clicks on the Home/Up button, so long
  1125. // as you specify a parent activity in AndroidManifest.xml.
  1126. int id = item.getItemId();
  1127.  
  1128. //noinspection SimplifiableIfStatement
  1129. if (id == R.id.action_settings) {
  1130. return true;
  1131. }
  1132.  
  1133. return super.onOptionsItemSelected(item);
  1134. }
  1135. }package com.example.programmingknowledge.simpleloginapp;
  1136.  
  1137. import android.content.Intent;
  1138. import android.support.v7.app.ActionBarActivity;
  1139. import android.os.Bundle;
  1140. import android.view.Menu;
  1141. import android.view.MenuItem;
  1142. import android.view.View;
  1143. import android.widget.Button;
  1144. import android.widget.EditText;
  1145. import android.widget.TextView;
  1146. import android.widget.Toast;
  1147.  
  1148.  
  1149. public class Login extends ActionBarActivity {
  1150. private static EditText username;
  1151. private static EditText password;
  1152. private static TextView attempts;
  1153. private static Button login_btn;
  1154. int attempt_counter = 5;
  1155. @Override
  1156. protected void onCreate(Bundle savedInstanceState) {
  1157. super.onCreate(savedInstanceState);
  1158. setContentView(R.layout.activity_login);
  1159. LoginButton();
  1160. }
  1161.  
  1162. public void LoginButton() {
  1163. username = (EditText)findViewById(R.id.editText_user);
  1164. password = (EditText)findViewById(R.id.editText_password);
  1165. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1166. login_btn = (Button)findViewById(R.id.button_login);
  1167.  
  1168. attempts.setText(Integer.toString(attempt_counter));
  1169.  
  1170. login_btn.setOnClickListener(
  1171. new View.OnClickListener() {
  1172. @Override
  1173. public void onClick(View v) {
  1174. if(username.getText().toString().equals("user") &&
  1175. password.getText().toString().equals("pass") ) {
  1176. Toast.makeText(Login.this,"User and Password is correct",
  1177. Toast.LENGTH_SHORT).show();
  1178. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1179. startActivity(intent);
  1180. } else {
  1181. Toast.makeText(Login.this,"User and Password is not correct",
  1182. Toast.LENGTH_SHORT).show();
  1183. attempt_counter--;
  1184. attempts.setText(Integer.toString(attempt_counter));
  1185. if(attempt_counter == 0){
  1186. login_btn.setEnabled(false);
  1187. }
  1188. }
  1189.  
  1190. }
  1191. }
  1192. );
  1193. }
  1194.  
  1195. @Override
  1196. public boolean onCreateOptionsMenu(Menu menu) {
  1197. // Inflate the menu; this adds items to the action bar if it is present.
  1198. getMenuInflater().inflate(R.menu.menu_login, menu);
  1199. return true;
  1200. }
  1201.  
  1202. @Override
  1203. public boolean onOptionsItemSelected(MenuItem item) {
  1204. // Handle action bar item clicks here. The action bar will
  1205. // automatically handle clicks on the Home/Up button, so long
  1206. // as you specify a parent activity in AndroidManifest.xml.
  1207. int id = item.getItemId();
  1208.  
  1209. //noinspection SimplifiableIfStatement
  1210. if (id == R.id.action_settings) {
  1211. return true;
  1212. }
  1213.  
  1214. return super.onOptionsItemSelected(item);
  1215. }
  1216. }package com.example.programmingknowledge.simpleloginapp;
  1217.  
  1218. import android.content.Intent;
  1219. import android.support.v7.app.ActionBarActivity;
  1220. import android.os.Bundle;
  1221. import android.view.Menu;
  1222. import android.view.MenuItem;
  1223. import android.view.View;
  1224. import android.widget.Button;
  1225. import android.widget.EditText;
  1226. import android.widget.TextView;
  1227. import android.widget.Toast;
  1228.  
  1229.  
  1230. public class Login extends ActionBarActivity {
  1231. private static EditText username;
  1232. private static EditText password;
  1233. private static TextView attempts;
  1234. private static Button login_btn;
  1235. int attempt_counter = 5;
  1236. @Override
  1237. protected void onCreate(Bundle savedInstanceState) {
  1238. super.onCreate(savedInstanceState);
  1239. setContentView(R.layout.activity_login);
  1240. LoginButton();
  1241. }
  1242.  
  1243. public void LoginButton() {
  1244. username = (EditText)findViewById(R.id.editText_user);
  1245. password = (EditText)findViewById(R.id.editText_password);
  1246. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1247. login_btn = (Button)findViewById(R.id.button_login);
  1248.  
  1249. attempts.setText(Integer.toString(attempt_counter));
  1250.  
  1251. login_btn.setOnClickListener(
  1252. new View.OnClickListener() {
  1253. @Override
  1254. public void onClick(View v) {
  1255. if(username.getText().toString().equals("user") &&
  1256. password.getText().toString().equals("pass") ) {
  1257. Toast.makeText(Login.this,"User and Password is correct",
  1258. Toast.LENGTH_SHORT).show();
  1259. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1260. startActivity(intent);
  1261. } else {
  1262. Toast.makeText(Login.this,"User and Password is not correct",
  1263. Toast.LENGTH_SHORT).show();
  1264. attempt_counter--;
  1265. attempts.setText(Integer.toString(attempt_counter));
  1266. if(attempt_counter == 0){
  1267. login_btn.setEnabled(false);
  1268. }
  1269. }
  1270.  
  1271. }
  1272. }
  1273. );
  1274. }
  1275.  
  1276. @Override
  1277. public boolean onCreateOptionsMenu(Menu menu) {
  1278. // Inflate the menu; this adds items to the action bar if it is present.
  1279. getMenuInflater().inflate(R.menu.menu_login, menu);
  1280. return true;
  1281. }
  1282.  
  1283. @Override
  1284. public boolean onOptionsItemSelected(MenuItem item) {
  1285. // Handle action bar item clicks here. The action bar will
  1286. // automatically handle clicks on the Home/Up button, so long
  1287. // as you specify a parent activity in AndroidManifest.xml.
  1288. int id = item.getItemId();
  1289.  
  1290. //noinspection SimplifiableIfStatement
  1291. if (id == R.id.action_settings) {
  1292. return true;
  1293. }
  1294.  
  1295. return super.onOptionsItemSelected(item);
  1296. }
  1297. }package com.example.programmingknowledge.simpleloginapp;
  1298.  
  1299. import android.content.Intent;
  1300. import android.support.v7.app.ActionBarActivity;
  1301. import android.os.Bundle;
  1302. import android.view.Menu;
  1303. import android.view.MenuItem;
  1304. import android.view.View;
  1305. import android.widget.Button;
  1306. import android.widget.EditText;
  1307. import android.widget.TextView;
  1308. import android.widget.Toast;
  1309.  
  1310.  
  1311. public class Login extends ActionBarActivity {
  1312. private static EditText username;
  1313. private static EditText password;
  1314. private static TextView attempts;
  1315. private static Button login_btn;
  1316. int attempt_counter = 5;
  1317. @Override
  1318. protected void onCreate(Bundle savedInstanceState) {
  1319. super.onCreate(savedInstanceState);
  1320. setContentView(R.layout.activity_login);
  1321. LoginButton();
  1322. }
  1323.  
  1324. public void LoginButton() {
  1325. username = (EditText)findViewById(R.id.editText_user);
  1326. password = (EditText)findViewById(R.id.editText_password);
  1327. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1328. login_btn = (Button)findViewById(R.id.button_login);
  1329.  
  1330. attempts.setText(Integer.toString(attempt_counter));
  1331.  
  1332. login_btn.setOnClickListener(
  1333. new View.OnClickListener() {
  1334. @Override
  1335. public void onClick(View v) {
  1336. if(username.getText().toString().equals("user") &&
  1337. password.getText().toString().equals("pass") ) {
  1338. Toast.makeText(Login.this,"User and Password is correct",
  1339. Toast.LENGTH_SHORT).show();
  1340. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1341. startActivity(intent);
  1342. } else {
  1343. Toast.makeText(Login.this,"User and Password is not correct",
  1344. Toast.LENGTH_SHORT).show();
  1345. attempt_counter--;
  1346. attempts.setText(Integer.toString(attempt_counter));
  1347. if(attempt_counter == 0){
  1348. login_btn.setEnabled(false);
  1349. }
  1350. }
  1351.  
  1352. }
  1353. }
  1354. );
  1355. }
  1356.  
  1357. @Override
  1358. public boolean onCreateOptionsMenu(Menu menu) {
  1359. // Inflate the menu; this adds items to the action bar if it is present.
  1360. getMenuInflater().inflate(R.menu.menu_login, menu);
  1361. return true;
  1362. }
  1363.  
  1364. @Override
  1365. public boolean onOptionsItemSelected(MenuItem item) {
  1366. // Handle action bar item clicks here. The action bar will
  1367. // automatically handle clicks on the Home/Up button, so long
  1368. // as you specify a parent activity in AndroidManifest.xml.
  1369. int id = item.getItemId();
  1370.  
  1371. //noinspection SimplifiableIfStatement
  1372. if (id == R.id.action_settings) {
  1373. return true;
  1374. }
  1375.  
  1376. return super.onOptionsItemSelected(item);
  1377. }
  1378. }package com.example.programmingknowledge.simpleloginapp;
  1379.  
  1380. import android.content.Intent;
  1381. import android.support.v7.app.ActionBarActivity;
  1382. import android.os.Bundle;
  1383. import android.view.Menu;
  1384. import android.view.MenuItem;
  1385. import android.view.View;
  1386. import android.widget.Button;
  1387. import android.widget.EditText;
  1388. import android.widget.TextView;
  1389. import android.widget.Toast;
  1390.  
  1391.  
  1392. public class Login extends ActionBarActivity {
  1393. private static EditText username;
  1394. private static EditText password;
  1395. private static TextView attempts;
  1396. private static Button login_btn;
  1397. int attempt_counter = 5;
  1398. @Override
  1399. protected void onCreate(Bundle savedInstanceState) {
  1400. super.onCreate(savedInstanceState);
  1401. setContentView(R.layout.activity_login);
  1402. LoginButton();
  1403. }
  1404.  
  1405. public void LoginButton() {
  1406. username = (EditText)findViewById(R.id.editText_user);
  1407. password = (EditText)findViewById(R.id.editText_password);
  1408. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1409. login_btn = (Button)findViewById(R.id.button_login);
  1410.  
  1411. attempts.setText(Integer.toString(attempt_counter));
  1412.  
  1413. login_btn.setOnClickListener(
  1414. new View.OnClickListener() {
  1415. @Override
  1416. public void onClick(View v) {
  1417. if(username.getText().toString().equals("user") &&
  1418. password.getText().toString().equals("pass") ) {
  1419. Toast.makeText(Login.this,"User and Password is correct",
  1420. Toast.LENGTH_SHORT).show();
  1421. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1422. startActivity(intent);
  1423. } else {
  1424. Toast.makeText(Login.this,"User and Password is not correct",
  1425. Toast.LENGTH_SHORT).show();
  1426. attempt_counter--;
  1427. attempts.setText(Integer.toString(attempt_counter));
  1428. if(attempt_counter == 0){
  1429. login_btn.setEnabled(false);
  1430. }
  1431. }
  1432.  
  1433. }
  1434. }
  1435. );
  1436. }
  1437.  
  1438. @Override
  1439. public boolean onCreateOptionsMenu(Menu menu) {
  1440. // Inflate the menu; this adds items to the action bar if it is present.
  1441. getMenuInflater().inflate(R.menu.menu_login, menu);
  1442. return true;
  1443. }
  1444.  
  1445. @Override
  1446. public boolean onOptionsItemSelected(MenuItem item) {
  1447. // Handle action bar item clicks here. The action bar will
  1448. // automatically handle clicks on the Home/Up button, so long
  1449. // as you specify a parent activity in AndroidManifest.xml.
  1450. int id = item.getItemId();
  1451.  
  1452. //noinspection SimplifiableIfStatement
  1453. if (id == R.id.action_settings) {
  1454. return true;
  1455. }
  1456.  
  1457. return super.onOptionsItemSelected(item);
  1458. }
  1459. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement