Advertisement
Krizzdawg

Untitled

Dec 4th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 110.36 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. }package com.example.programmingknowledge.simpleloginapp;
  1460.  
  1461. import android.content.Intent;
  1462. import android.support.v7.app.ActionBarActivity;
  1463. import android.os.Bundle;
  1464. import android.view.Menu;
  1465. import android.view.MenuItem;
  1466. import android.view.View;
  1467. import android.widget.Button;
  1468. import android.widget.EditText;
  1469. import android.widget.TextView;
  1470. import android.widget.Toast;
  1471.  
  1472.  
  1473. public class Login extends ActionBarActivity {
  1474. private static EditText username;
  1475. private static EditText password;
  1476. private static TextView attempts;
  1477. private static Button login_btn;
  1478. int attempt_counter = 5;
  1479. @Override
  1480. protected void onCreate(Bundle savedInstanceState) {
  1481. super.onCreate(savedInstanceState);
  1482. setContentView(R.layout.activity_login);
  1483. LoginButton();
  1484. }
  1485.  
  1486. public void LoginButton() {
  1487. username = (EditText)findViewById(R.id.editText_user);
  1488. password = (EditText)findViewById(R.id.editText_password);
  1489. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1490. login_btn = (Button)findViewById(R.id.button_login);
  1491.  
  1492. attempts.setText(Integer.toString(attempt_counter));
  1493.  
  1494. login_btn.setOnClickListener(
  1495. new View.OnClickListener() {
  1496. @Override
  1497. public void onClick(View v) {
  1498. if(username.getText().toString().equals("user") &&
  1499. password.getText().toString().equals("pass") ) {
  1500. Toast.makeText(Login.this,"User and Password is correct",
  1501. Toast.LENGTH_SHORT).show();
  1502. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1503. startActivity(intent);
  1504. } else {
  1505. Toast.makeText(Login.this,"User and Password is not correct",
  1506. Toast.LENGTH_SHORT).show();
  1507. attempt_counter--;
  1508. attempts.setText(Integer.toString(attempt_counter));
  1509. if(attempt_counter == 0){
  1510. login_btn.setEnabled(false);
  1511. }
  1512. }
  1513.  
  1514. }
  1515. }
  1516. );
  1517. }
  1518.  
  1519. @Override
  1520. public boolean onCreateOptionsMenu(Menu menu) {
  1521. // Inflate the menu; this adds items to the action bar if it is present.
  1522. getMenuInflater().inflate(R.menu.menu_login, menu);
  1523. return true;
  1524. }
  1525.  
  1526. @Override
  1527. public boolean onOptionsItemSelected(MenuItem item) {
  1528. // Handle action bar item clicks here. The action bar will
  1529. // automatically handle clicks on the Home/Up button, so long
  1530. // as you specify a parent activity in AndroidManifest.xml.
  1531. int id = item.getItemId();
  1532.  
  1533. //noinspection SimplifiableIfStatement
  1534. if (id == R.id.action_settings) {
  1535. return true;
  1536. }
  1537.  
  1538. return super.onOptionsItemSelected(item);
  1539. }
  1540. }package com.example.programmingknowledge.simpleloginapp;
  1541.  
  1542. import android.content.Intent;
  1543. import android.support.v7.app.ActionBarActivity;
  1544. import android.os.Bundle;
  1545. import android.view.Menu;
  1546. import android.view.MenuItem;
  1547. import android.view.View;
  1548. import android.widget.Button;
  1549. import android.widget.EditText;
  1550. import android.widget.TextView;
  1551. import android.widget.Toast;
  1552.  
  1553.  
  1554. public class Login extends ActionBarActivity {
  1555. private static EditText username;
  1556. private static EditText password;
  1557. private static TextView attempts;
  1558. private static Button login_btn;
  1559. int attempt_counter = 5;
  1560. @Override
  1561. protected void onCreate(Bundle savedInstanceState) {
  1562. super.onCreate(savedInstanceState);
  1563. setContentView(R.layout.activity_login);
  1564. LoginButton();
  1565. }
  1566.  
  1567. public void LoginButton() {
  1568. username = (EditText)findViewById(R.id.editText_user);
  1569. password = (EditText)findViewById(R.id.editText_password);
  1570. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1571. login_btn = (Button)findViewById(R.id.button_login);
  1572.  
  1573. attempts.setText(Integer.toString(attempt_counter));
  1574.  
  1575. login_btn.setOnClickListener(
  1576. new View.OnClickListener() {
  1577. @Override
  1578. public void onClick(View v) {
  1579. if(username.getText().toString().equals("user") &&
  1580. password.getText().toString().equals("pass") ) {
  1581. Toast.makeText(Login.this,"User and Password is correct",
  1582. Toast.LENGTH_SHORT).show();
  1583. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1584. startActivity(intent);
  1585. } else {
  1586. Toast.makeText(Login.this,"User and Password is not correct",
  1587. Toast.LENGTH_SHORT).show();
  1588. attempt_counter--;
  1589. attempts.setText(Integer.toString(attempt_counter));
  1590. if(attempt_counter == 0){
  1591. login_btn.setEnabled(false);
  1592. }
  1593. }
  1594.  
  1595. }
  1596. }
  1597. );
  1598. }
  1599.  
  1600. @Override
  1601. public boolean onCreateOptionsMenu(Menu menu) {
  1602. // Inflate the menu; this adds items to the action bar if it is present.
  1603. getMenuInflater().inflate(R.menu.menu_login, menu);
  1604. return true;
  1605. }
  1606.  
  1607. @Override
  1608. public boolean onOptionsItemSelected(MenuItem item) {
  1609. // Handle action bar item clicks here. The action bar will
  1610. // automatically handle clicks on the Home/Up button, so long
  1611. // as you specify a parent activity in AndroidManifest.xml.
  1612. int id = item.getItemId();
  1613.  
  1614. //noinspection SimplifiableIfStatement
  1615. if (id == R.id.action_settings) {
  1616. return true;
  1617. }
  1618.  
  1619. return super.onOptionsItemSelected(item);
  1620. }
  1621. }package com.example.programmingknowledge.simpleloginapp;
  1622.  
  1623. import android.content.Intent;
  1624. import android.support.v7.app.ActionBarActivity;
  1625. import android.os.Bundle;
  1626. import android.view.Menu;
  1627. import android.view.MenuItem;
  1628. import android.view.View;
  1629. import android.widget.Button;
  1630. import android.widget.EditText;
  1631. import android.widget.TextView;
  1632. import android.widget.Toast;
  1633.  
  1634.  
  1635. public class Login extends ActionBarActivity {
  1636. private static EditText username;
  1637. private static EditText password;
  1638. private static TextView attempts;
  1639. private static Button login_btn;
  1640. int attempt_counter = 5;
  1641. @Override
  1642. protected void onCreate(Bundle savedInstanceState) {
  1643. super.onCreate(savedInstanceState);
  1644. setContentView(R.layout.activity_login);
  1645. LoginButton();
  1646. }
  1647.  
  1648. public void LoginButton() {
  1649. username = (EditText)findViewById(R.id.editText_user);
  1650. password = (EditText)findViewById(R.id.editText_password);
  1651. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1652. login_btn = (Button)findViewById(R.id.button_login);
  1653.  
  1654. attempts.setText(Integer.toString(attempt_counter));
  1655.  
  1656. login_btn.setOnClickListener(
  1657. new View.OnClickListener() {
  1658. @Override
  1659. public void onClick(View v) {
  1660. if(username.getText().toString().equals("user") &&
  1661. password.getText().toString().equals("pass") ) {
  1662. Toast.makeText(Login.this,"User and Password is correct",
  1663. Toast.LENGTH_SHORT).show();
  1664. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1665. startActivity(intent);
  1666. } else {
  1667. Toast.makeText(Login.this,"User and Password is not correct",
  1668. Toast.LENGTH_SHORT).show();
  1669. attempt_counter--;
  1670. attempts.setText(Integer.toString(attempt_counter));
  1671. if(attempt_counter == 0){
  1672. login_btn.setEnabled(false);
  1673. }
  1674. }
  1675.  
  1676. }
  1677. }
  1678. );
  1679. }
  1680.  
  1681. @Override
  1682. public boolean onCreateOptionsMenu(Menu menu) {
  1683. // Inflate the menu; this adds items to the action bar if it is present.
  1684. getMenuInflater().inflate(R.menu.menu_login, menu);
  1685. return true;
  1686. }
  1687.  
  1688. @Override
  1689. public boolean onOptionsItemSelected(MenuItem item) {
  1690. // Handle action bar item clicks here. The action bar will
  1691. // automatically handle clicks on the Home/Up button, so long
  1692. // as you specify a parent activity in AndroidManifest.xml.
  1693. int id = item.getItemId();
  1694.  
  1695. //noinspection SimplifiableIfStatement
  1696. if (id == R.id.action_settings) {
  1697. return true;
  1698. }
  1699.  
  1700. return super.onOptionsItemSelected(item);
  1701. }
  1702. }package com.example.programmingknowledge.simpleloginapp;
  1703.  
  1704. import android.content.Intent;
  1705. import android.support.v7.app.ActionBarActivity;
  1706. import android.os.Bundle;
  1707. import android.view.Menu;
  1708. import android.view.MenuItem;
  1709. import android.view.View;
  1710. import android.widget.Button;
  1711. import android.widget.EditText;
  1712. import android.widget.TextView;
  1713. import android.widget.Toast;
  1714.  
  1715.  
  1716. public class Login extends ActionBarActivity {
  1717. private static EditText username;
  1718. private static EditText password;
  1719. private static TextView attempts;
  1720. private static Button login_btn;
  1721. int attempt_counter = 5;
  1722. @Override
  1723. protected void onCreate(Bundle savedInstanceState) {
  1724. super.onCreate(savedInstanceState);
  1725. setContentView(R.layout.activity_login);
  1726. LoginButton();
  1727. }
  1728.  
  1729. public void LoginButton() {
  1730. username = (EditText)findViewById(R.id.editText_user);
  1731. password = (EditText)findViewById(R.id.editText_password);
  1732. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1733. login_btn = (Button)findViewById(R.id.button_login);
  1734.  
  1735. attempts.setText(Integer.toString(attempt_counter));
  1736.  
  1737. login_btn.setOnClickListener(
  1738. new View.OnClickListener() {
  1739. @Override
  1740. public void onClick(View v) {
  1741. if(username.getText().toString().equals("user") &&
  1742. password.getText().toString().equals("pass") ) {
  1743. Toast.makeText(Login.this,"User and Password is correct",
  1744. Toast.LENGTH_SHORT).show();
  1745. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1746. startActivity(intent);
  1747. } else {
  1748. Toast.makeText(Login.this,"User and Password is not correct",
  1749. Toast.LENGTH_SHORT).show();
  1750. attempt_counter--;
  1751. attempts.setText(Integer.toString(attempt_counter));
  1752. if(attempt_counter == 0){
  1753. login_btn.setEnabled(false);
  1754. }
  1755. }
  1756.  
  1757. }
  1758. }
  1759. );
  1760. }
  1761.  
  1762. @Override
  1763. public boolean onCreateOptionsMenu(Menu menu) {
  1764. // Inflate the menu; this adds items to the action bar if it is present.
  1765. getMenuInflater().inflate(R.menu.menu_login, menu);
  1766. return true;
  1767. }
  1768.  
  1769. @Override
  1770. public boolean onOptionsItemSelected(MenuItem item) {
  1771. // Handle action bar item clicks here. The action bar will
  1772. // automatically handle clicks on the Home/Up button, so long
  1773. // as you specify a parent activity in AndroidManifest.xml.
  1774. int id = item.getItemId();
  1775.  
  1776. //noinspection SimplifiableIfStatement
  1777. if (id == R.id.action_settings) {
  1778. return true;
  1779. }
  1780.  
  1781. return super.onOptionsItemSelected(item);
  1782. }
  1783. }package com.example.programmingknowledge.simpleloginapp;
  1784.  
  1785. import android.content.Intent;
  1786. import android.support.v7.app.ActionBarActivity;
  1787. import android.os.Bundle;
  1788. import android.view.Menu;
  1789. import android.view.MenuItem;
  1790. import android.view.View;
  1791. import android.widget.Button;
  1792. import android.widget.EditText;
  1793. import android.widget.TextView;
  1794. import android.widget.Toast;
  1795.  
  1796.  
  1797. public class Login extends ActionBarActivity {
  1798. private static EditText username;
  1799. private static EditText password;
  1800. private static TextView attempts;
  1801. private static Button login_btn;
  1802. int attempt_counter = 5;
  1803. @Override
  1804. protected void onCreate(Bundle savedInstanceState) {
  1805. super.onCreate(savedInstanceState);
  1806. setContentView(R.layout.activity_login);
  1807. LoginButton();
  1808. }
  1809.  
  1810. public void LoginButton() {
  1811. username = (EditText)findViewById(R.id.editText_user);
  1812. password = (EditText)findViewById(R.id.editText_password);
  1813. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1814. login_btn = (Button)findViewById(R.id.button_login);
  1815.  
  1816. attempts.setText(Integer.toString(attempt_counter));
  1817.  
  1818. login_btn.setOnClickListener(
  1819. new View.OnClickListener() {
  1820. @Override
  1821. public void onClick(View v) {
  1822. if(username.getText().toString().equals("user") &&
  1823. password.getText().toString().equals("pass") ) {
  1824. Toast.makeText(Login.this,"User and Password is correct",
  1825. Toast.LENGTH_SHORT).show();
  1826. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1827. startActivity(intent);
  1828. } else {
  1829. Toast.makeText(Login.this,"User and Password is not correct",
  1830. Toast.LENGTH_SHORT).show();
  1831. attempt_counter--;
  1832. attempts.setText(Integer.toString(attempt_counter));
  1833. if(attempt_counter == 0){
  1834. login_btn.setEnabled(false);
  1835. }
  1836. }
  1837.  
  1838. }
  1839. }
  1840. );
  1841. }
  1842.  
  1843. @Override
  1844. public boolean onCreateOptionsMenu(Menu menu) {
  1845. // Inflate the menu; this adds items to the action bar if it is present.
  1846. getMenuInflater().inflate(R.menu.menu_login, menu);
  1847. return true;
  1848. }
  1849.  
  1850. @Override
  1851. public boolean onOptionsItemSelected(MenuItem item) {
  1852. // Handle action bar item clicks here. The action bar will
  1853. // automatically handle clicks on the Home/Up button, so long
  1854. // as you specify a parent activity in AndroidManifest.xml.
  1855. int id = item.getItemId();
  1856.  
  1857. //noinspection SimplifiableIfStatement
  1858. if (id == R.id.action_settings) {
  1859. return true;
  1860. }
  1861.  
  1862. return super.onOptionsItemSelected(item);
  1863. }
  1864. }package com.example.programmingknowledge.simpleloginapp;
  1865.  
  1866. import android.content.Intent;
  1867. import android.support.v7.app.ActionBarActivity;
  1868. import android.os.Bundle;
  1869. import android.view.Menu;
  1870. import android.view.MenuItem;
  1871. import android.view.View;
  1872. import android.widget.Button;
  1873. import android.widget.EditText;
  1874. import android.widget.TextView;
  1875. import android.widget.Toast;
  1876.  
  1877.  
  1878. public class Login extends ActionBarActivity {
  1879. private static EditText username;
  1880. private static EditText password;
  1881. private static TextView attempts;
  1882. private static Button login_btn;
  1883. int attempt_counter = 5;
  1884. @Override
  1885. protected void onCreate(Bundle savedInstanceState) {
  1886. super.onCreate(savedInstanceState);
  1887. setContentView(R.layout.activity_login);
  1888. LoginButton();
  1889. }
  1890.  
  1891. public void LoginButton() {
  1892. username = (EditText)findViewById(R.id.editText_user);
  1893. password = (EditText)findViewById(R.id.editText_password);
  1894. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1895. login_btn = (Button)findViewById(R.id.button_login);
  1896.  
  1897. attempts.setText(Integer.toString(attempt_counter));
  1898.  
  1899. login_btn.setOnClickListener(
  1900. new View.OnClickListener() {
  1901. @Override
  1902. public void onClick(View v) {
  1903. if(username.getText().toString().equals("user") &&
  1904. password.getText().toString().equals("pass") ) {
  1905. Toast.makeText(Login.this,"User and Password is correct",
  1906. Toast.LENGTH_SHORT).show();
  1907. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1908. startActivity(intent);
  1909. } else {
  1910. Toast.makeText(Login.this,"User and Password is not correct",
  1911. Toast.LENGTH_SHORT).show();
  1912. attempt_counter--;
  1913. attempts.setText(Integer.toString(attempt_counter));
  1914. if(attempt_counter == 0){
  1915. login_btn.setEnabled(false);
  1916. }
  1917. }
  1918.  
  1919. }
  1920. }
  1921. );
  1922. }
  1923.  
  1924. @Override
  1925. public boolean onCreateOptionsMenu(Menu menu) {
  1926. // Inflate the menu; this adds items to the action bar if it is present.
  1927. getMenuInflater().inflate(R.menu.menu_login, menu);
  1928. return true;
  1929. }
  1930.  
  1931. @Override
  1932. public boolean onOptionsItemSelected(MenuItem item) {
  1933. // Handle action bar item clicks here. The action bar will
  1934. // automatically handle clicks on the Home/Up button, so long
  1935. // as you specify a parent activity in AndroidManifest.xml.
  1936. int id = item.getItemId();
  1937.  
  1938. //noinspection SimplifiableIfStatement
  1939. if (id == R.id.action_settings) {
  1940. return true;
  1941. }
  1942.  
  1943. return super.onOptionsItemSelected(item);
  1944. }
  1945. }package com.example.programmingknowledge.simpleloginapp;
  1946.  
  1947. import android.content.Intent;
  1948. import android.support.v7.app.ActionBarActivity;
  1949. import android.os.Bundle;
  1950. import android.view.Menu;
  1951. import android.view.MenuItem;
  1952. import android.view.View;
  1953. import android.widget.Button;
  1954. import android.widget.EditText;
  1955. import android.widget.TextView;
  1956. import android.widget.Toast;
  1957.  
  1958.  
  1959. public class Login extends ActionBarActivity {
  1960. private static EditText username;
  1961. private static EditText password;
  1962. private static TextView attempts;
  1963. private static Button login_btn;
  1964. int attempt_counter = 5;
  1965. @Override
  1966. protected void onCreate(Bundle savedInstanceState) {
  1967. super.onCreate(savedInstanceState);
  1968. setContentView(R.layout.activity_login);
  1969. LoginButton();
  1970. }
  1971.  
  1972. public void LoginButton() {
  1973. username = (EditText)findViewById(R.id.editText_user);
  1974. password = (EditText)findViewById(R.id.editText_password);
  1975. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  1976. login_btn = (Button)findViewById(R.id.button_login);
  1977.  
  1978. attempts.setText(Integer.toString(attempt_counter));
  1979.  
  1980. login_btn.setOnClickListener(
  1981. new View.OnClickListener() {
  1982. @Override
  1983. public void onClick(View v) {
  1984. if(username.getText().toString().equals("user") &&
  1985. password.getText().toString().equals("pass") ) {
  1986. Toast.makeText(Login.this,"User and Password is correct",
  1987. Toast.LENGTH_SHORT).show();
  1988. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  1989. startActivity(intent);
  1990. } else {
  1991. Toast.makeText(Login.this,"User and Password is not correct",
  1992. Toast.LENGTH_SHORT).show();
  1993. attempt_counter--;
  1994. attempts.setText(Integer.toString(attempt_counter));
  1995. if(attempt_counter == 0){
  1996. login_btn.setEnabled(false);
  1997. }
  1998. }
  1999.  
  2000. }
  2001. }
  2002. );
  2003. }
  2004.  
  2005. @Override
  2006. public boolean onCreateOptionsMenu(Menu menu) {
  2007. // Inflate the menu; this adds items to the action bar if it is present.
  2008. getMenuInflater().inflate(R.menu.menu_login, menu);
  2009. return true;
  2010. }
  2011.  
  2012. @Override
  2013. public boolean onOptionsItemSelected(MenuItem item) {
  2014. // Handle action bar item clicks here. The action bar will
  2015. // automatically handle clicks on the Home/Up button, so long
  2016. // as you specify a parent activity in AndroidManifest.xml.
  2017. int id = item.getItemId();
  2018.  
  2019. //noinspection SimplifiableIfStatement
  2020. if (id == R.id.action_settings) {
  2021. return true;
  2022. }
  2023.  
  2024. return super.onOptionsItemSelected(item);
  2025. }
  2026. }fvpackage com.example.programmingknowledge.simpleloginapp;
  2027.  
  2028. import android.content.Intent;
  2029. import android.support.v7.app.ActionBarActivity;
  2030. import android.os.Bundle;
  2031. import android.view.Menu;
  2032. import android.view.MenuItem;
  2033. import android.view.View;
  2034. import android.widget.Button;
  2035. import android.widget.EditText;
  2036. import android.widget.TextView;
  2037. import android.widget.Toast;
  2038.  
  2039.  
  2040. public class Login extends ActionBarActivity {
  2041. private static EditText username;
  2042. private static EditText password;
  2043. private static TextView attempts;
  2044. private static Button login_btn;
  2045. int attempt_counter = 5;
  2046. @Override
  2047. protected void onCreate(Bundle savedInstanceState) {
  2048. super.onCreate(savedInstanceState);
  2049. setContentView(R.layout.activity_login);
  2050. LoginButton();
  2051. }
  2052.  
  2053. public void LoginButton() {
  2054. username = (EditText)findViewById(R.id.editText_user);
  2055. password = (EditText)findViewById(R.id.editText_password);
  2056. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2057. login_btn = (Button)findViewById(R.id.button_login);
  2058.  
  2059. attempts.setText(Integer.toString(attempt_counter));
  2060.  
  2061. login_btn.setOnClickListener(
  2062. new View.OnClickListener() {
  2063. @Override
  2064. public void onClick(View v) {
  2065. if(username.getText().toString().equals("user") &&
  2066. password.getText().toString().equals("pass") ) {
  2067. Toast.makeText(Login.this,"User and Password is correct",
  2068. Toast.LENGTH_SHORT).show();
  2069. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2070. startActivity(intent);
  2071. } else {
  2072. Toast.makeText(Login.this,"User and Password is not correct",
  2073. Toast.LENGTH_SHORT).show();
  2074. attempt_counter--;
  2075. attempts.setText(Integer.toString(attempt_counter));
  2076. if(attempt_counter == 0){
  2077. login_btn.setEnabled(false);
  2078. }
  2079. }
  2080.  
  2081. }
  2082. }
  2083. );
  2084. }
  2085.  
  2086. @Override
  2087. public boolean onCreateOptionsMenu(Menu menu) {
  2088. // Inflate the menu; this adds items to the action bar if it is present.
  2089. getMenuInflater().inflate(R.menu.menu_login, menu);
  2090. return true;
  2091. }
  2092.  
  2093. @Override
  2094. public boolean onOptionsItemSelected(MenuItem item) {
  2095. // Handle action bar item clicks here. The action bar will
  2096. // automatically handle clicks on the Home/Up button, so long
  2097. // as you specify a parent activity in AndroidManifest.xml.
  2098. int id = item.getItemId();
  2099.  
  2100. //noinspection SimplifiableIfStatement
  2101. if (id == R.id.action_settings) {
  2102. return true;
  2103. }
  2104.  
  2105. return super.onOptionsItemSelected(item);
  2106. }
  2107. }package com.example.programmingknowledge.simpleloginapp;
  2108.  
  2109. import android.content.Intent;
  2110. import android.support.v7.app.ActionBarActivity;
  2111. import android.os.Bundle;
  2112. import android.view.Menu;
  2113. import android.view.MenuItem;
  2114. import android.view.View;
  2115. import android.widget.Button;
  2116. import android.widget.EditText;
  2117. import android.widget.TextView;
  2118. import android.widget.Toast;
  2119.  
  2120.  
  2121. public class Login extends ActionBarActivity {
  2122. private static EditText username;
  2123. private static EditText password;
  2124. private static TextView attempts;
  2125. private static Button login_btn;
  2126. int attempt_counter = 5;
  2127. @Override
  2128. protected void onCreate(Bundle savedInstanceState) {
  2129. super.onCreate(savedInstanceState);
  2130. setContentView(R.layout.activity_login);
  2131. LoginButton();
  2132. }
  2133.  
  2134. public void LoginButton() {
  2135. username = (EditText)findViewById(R.id.editText_user);
  2136. password = (EditText)findViewById(R.id.editText_password);
  2137. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2138. login_btn = (Button)findViewById(R.id.button_login);
  2139.  
  2140. attempts.setText(Integer.toString(attempt_counter));
  2141.  
  2142. login_btn.setOnClickListener(
  2143. new View.OnClickListener() {
  2144. @Override
  2145. public void onClick(View v) {
  2146. if(username.getText().toString().equals("user") &&
  2147. password.getText().toString().equals("pass") ) {
  2148. Toast.makeText(Login.this,"User and Password is correct",
  2149. Toast.LENGTH_SHORT).show();
  2150. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2151. startActivity(intent);
  2152. } else {
  2153. Toast.makeText(Login.this,"User and Password is not correct",
  2154. Toast.LENGTH_SHORT).show();
  2155. attempt_counter--;
  2156. attempts.setText(Integer.toString(attempt_counter));
  2157. if(attempt_counter == 0){
  2158. login_btn.setEnabled(false);
  2159. }
  2160. }
  2161.  
  2162. }
  2163. }
  2164. );
  2165. }
  2166.  
  2167. @Override
  2168. public boolean onCreateOptionsMenu(Menu menu) {
  2169. // Inflate the menu; this adds items to the action bar if it is present.
  2170. getMenuInflater().inflate(R.menu.menu_login, menu);
  2171. return true;
  2172. }
  2173.  
  2174. @Override
  2175. public boolean onOptionsItemSelected(MenuItem item) {
  2176. // Handle action bar item clicks here. The action bar will
  2177. // automatically handle clicks on the Home/Up button, so long
  2178. // as you specify a parent activity in AndroidManifest.xml.
  2179. int id = item.getItemId();
  2180.  
  2181. //noinspection SimplifiableIfStatement
  2182. if (id == R.id.action_settings) {
  2183. return true;
  2184. }
  2185.  
  2186. return super.onOptionsItemSelected(item);
  2187. }
  2188. }package com.example.programmingknowledge.simpleloginapp;
  2189.  
  2190. import android.content.Intent;
  2191. import android.support.v7.app.ActionBarActivity;
  2192. import android.os.Bundle;
  2193. import android.view.Menu;
  2194. import android.view.MenuItem;
  2195. import android.view.View;
  2196. import android.widget.Button;
  2197. import android.widget.EditText;
  2198. import android.widget.TextView;
  2199. import android.widget.Toast;
  2200.  
  2201.  
  2202. public class Login extends ActionBarActivity {
  2203. private static EditText username;
  2204. private static EditText password;
  2205. private static TextView attempts;
  2206. private static Button login_btn;
  2207. int attempt_counter = 5;
  2208. @Override
  2209. protected void onCreate(Bundle savedInstanceState) {
  2210. super.onCreate(savedInstanceState);
  2211. setContentView(R.layout.activity_login);
  2212. LoginButton();
  2213. }
  2214.  
  2215. public void LoginButton() {
  2216. username = (EditText)findViewById(R.id.editText_user);
  2217. password = (EditText)findViewById(R.id.editText_password);
  2218. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2219. login_btn = (Button)findViewById(R.id.button_login);
  2220.  
  2221. attempts.setText(Integer.toString(attempt_counter));
  2222.  
  2223. login_btn.setOnClickListener(
  2224. new View.OnClickListener() {
  2225. @Override
  2226. public void onClick(View v) {
  2227. if(username.getText().toString().equals("user") &&
  2228. password.getText().toString().equals("pass") ) {
  2229. Toast.makeText(Login.this,"User and Password is correct",
  2230. Toast.LENGTH_SHORT).show();
  2231. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2232. startActivity(intent);
  2233. } else {
  2234. Toast.makeText(Login.this,"User and Password is not correct",
  2235. Toast.LENGTH_SHORT).show();
  2236. attempt_counter--;
  2237. attempts.setText(Integer.toString(attempt_counter));
  2238. if(attempt_counter == 0){
  2239. login_btn.setEnabled(false);
  2240. }
  2241. }
  2242.  
  2243. }
  2244. }
  2245. );
  2246. }
  2247.  
  2248. @Override
  2249. public boolean onCreateOptionsMenu(Menu menu) {
  2250. // Inflate the menu; this adds items to the action bar if it is present.
  2251. getMenuInflater().inflate(R.menu.menu_login, menu);
  2252. return true;
  2253. }
  2254.  
  2255. @Override
  2256. public boolean onOptionsItemSelected(MenuItem item) {
  2257. // Handle action bar item clicks here. The action bar will
  2258. // automatically handle clicks on the Home/Up button, so long
  2259. // as you specify a parent activity in AndroidManifest.xml.
  2260. int id = item.getItemId();
  2261.  
  2262. //noinspection SimplifiableIfStatement
  2263. if (id == R.id.action_settings) {
  2264. return true;
  2265. }
  2266.  
  2267. return super.onOptionsItemSelected(item);
  2268. }
  2269. }package com.example.programmingknowledge.simpleloginapp;
  2270.  
  2271. import android.content.Intent;
  2272. import android.support.v7.app.ActionBarActivity;
  2273. import android.os.Bundle;
  2274. import android.view.Menu;
  2275. import android.view.MenuItem;
  2276. import android.view.View;
  2277. import android.widget.Button;
  2278. import android.widget.EditText;
  2279. import android.widget.TextView;
  2280. import android.widget.Toast;
  2281.  
  2282.  
  2283. public class Login extends ActionBarActivity {
  2284. private static EditText username;
  2285. private static EditText password;
  2286. private static TextView attempts;
  2287. private static Button login_btn;
  2288. int attempt_counter = 5;
  2289. @Override
  2290. protected void onCreate(Bundle savedInstanceState) {
  2291. super.onCreate(savedInstanceState);
  2292. setContentView(R.layout.activity_login);
  2293. LoginButton();
  2294. }
  2295.  
  2296. public void LoginButton() {
  2297. username = (EditText)findViewById(R.id.editText_user);
  2298. password = (EditText)findViewById(R.id.editText_password);
  2299. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2300. login_btn = (Button)findViewById(R.id.button_login);
  2301.  
  2302. attempts.setText(Integer.toString(attempt_counter));
  2303.  
  2304. login_btn.setOnClickListener(
  2305. new View.OnClickListener() {
  2306. @Override
  2307. public void onClick(View v) {
  2308. if(username.getText().toString().equals("user") &&
  2309. password.getText().toString().equals("pass") ) {
  2310. Toast.makeText(Login.this,"User and Password is correct",
  2311. Toast.LENGTH_SHORT).show();
  2312. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2313. startActivity(intent);
  2314. } else {
  2315. Toast.makeText(Login.this,"User and Password is not correct",
  2316. Toast.LENGTH_SHORT).show();
  2317. attempt_counter--;
  2318. attempts.setText(Integer.toString(attempt_counter));
  2319. if(attempt_counter == 0){
  2320. login_btn.setEnabled(false);
  2321. }
  2322. }
  2323.  
  2324. }
  2325. }
  2326. );
  2327. }
  2328.  
  2329. @Override
  2330. public boolean onCreateOptionsMenu(Menu menu) {
  2331. // Inflate the menu; this adds items to the action bar if it is present.
  2332. getMenuInflater().inflate(R.menu.menu_login, menu);
  2333. return true;
  2334. }
  2335.  
  2336. @Override
  2337. public boolean onOptionsItemSelected(MenuItem item) {
  2338. // Handle action bar item clicks here. The action bar will
  2339. // automatically handle clicks on the Home/Up button, so long
  2340. // as you specify a parent activity in AndroidManifest.xml.
  2341. int id = item.getItemId();
  2342.  
  2343. //noinspection SimplifiableIfStatement
  2344. if (id == R.id.action_settings) {
  2345. return true;
  2346. }
  2347.  
  2348. return super.onOptionsItemSelected(item);
  2349. }
  2350. }package com.example.programmingknowledge.simpleloginapp;
  2351.  
  2352. import android.content.Intent;
  2353. import android.support.v7.app.ActionBarActivity;
  2354. import android.os.Bundle;
  2355. import android.view.Menu;
  2356. import android.view.MenuItem;
  2357. import android.view.View;
  2358. import android.widget.Button;
  2359. import android.widget.EditText;
  2360. import android.widget.TextView;
  2361. import android.widget.Toast;
  2362.  
  2363.  
  2364. public class Login extends ActionBarActivity {
  2365. private static EditText username;
  2366. private static EditText password;
  2367. private static TextView attempts;
  2368. private static Button login_btn;
  2369. int attempt_counter = 5;
  2370. @Override
  2371. protected void onCreate(Bundle savedInstanceState) {
  2372. super.onCreate(savedInstanceState);
  2373. setContentView(R.layout.activity_login);
  2374. LoginButton();
  2375. }
  2376.  
  2377. public void LoginButton() {
  2378. username = (EditText)findViewById(R.id.editText_user);
  2379. password = (EditText)findViewById(R.id.editText_password);
  2380. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2381. login_btn = (Button)findViewById(R.id.button_login);
  2382.  
  2383. attempts.setText(Integer.toString(attempt_counter));
  2384.  
  2385. login_btn.setOnClickListener(
  2386. new View.OnClickListener() {
  2387. @Override
  2388. public void onClick(View v) {
  2389. if(username.getText().toString().equals("user") &&
  2390. password.getText().toString().equals("pass") ) {
  2391. Toast.makeText(Login.this,"User and Password is correct",
  2392. Toast.LENGTH_SHORT).show();
  2393. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2394. startActivity(intent);
  2395. } else {
  2396. Toast.makeText(Login.this,"User and Password is not correct",
  2397. Toast.LENGTH_SHORT).show();
  2398. attempt_counter--;
  2399. attempts.setText(Integer.toString(attempt_counter));
  2400. if(attempt_counter == 0){
  2401. login_btn.setEnabled(false);
  2402. }
  2403. }
  2404.  
  2405. }
  2406. }
  2407. );
  2408. }
  2409.  
  2410. @Override
  2411. public boolean onCreateOptionsMenu(Menu menu) {
  2412. // Inflate the menu; this adds items to the action bar if it is present.
  2413. getMenuInflater().inflate(R.menu.menu_login, menu);
  2414. return true;
  2415. }
  2416.  
  2417. @Override
  2418. public boolean onOptionsItemSelected(MenuItem item) {
  2419. // Handle action bar item clicks here. The action bar will
  2420. // automatically handle clicks on the Home/Up button, so long
  2421. // as you specify a parent activity in AndroidManifest.xml.
  2422. int id = item.getItemId();
  2423.  
  2424. //noinspection SimplifiableIfStatement
  2425. if (id == R.id.action_settings) {
  2426. return true;
  2427. }
  2428.  
  2429. return super.onOptionsItemSelected(item);
  2430. }
  2431. }package com.example.programmingknowledge.simpleloginapp;
  2432.  
  2433. import android.content.Intent;
  2434. import android.support.v7.app.ActionBarActivity;
  2435. import android.os.Bundle;
  2436. import android.view.Menu;
  2437. import android.view.MenuItem;
  2438. import android.view.View;
  2439. import android.widget.Button;
  2440. import android.widget.EditText;
  2441. import android.widget.TextView;
  2442. import android.widget.Toast;
  2443.  
  2444.  
  2445. public class Login extends ActionBarActivity {
  2446. private static EditText username;
  2447. private static EditText password;
  2448. private static TextView attempts;
  2449. private static Button login_btn;
  2450. int attempt_counter = 5;
  2451. @Override
  2452. protected void onCreate(Bundle savedInstanceState) {
  2453. super.onCreate(savedInstanceState);
  2454. setContentView(R.layout.activity_login);
  2455. LoginButton();
  2456. }
  2457.  
  2458. public void LoginButton() {
  2459. username = (EditText)findViewById(R.id.editText_user);
  2460. password = (EditText)findViewById(R.id.editText_password);
  2461. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2462. login_btn = (Button)findViewById(R.id.button_login);
  2463.  
  2464. attempts.setText(Integer.toString(attempt_counter));
  2465.  
  2466. login_btn.setOnClickListener(
  2467. new View.OnClickListener() {
  2468. @Override
  2469. public void onClick(View v) {
  2470. if(username.getText().toString().equals("user") &&
  2471. password.getText().toString().equals("pass") ) {
  2472. Toast.makeText(Login.this,"User and Password is correct",
  2473. Toast.LENGTH_SHORT).show();
  2474. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2475. startActivity(intent);
  2476. } else {
  2477. Toast.makeText(Login.this,"User and Password is not correct",
  2478. Toast.LENGTH_SHORT).show();
  2479. attempt_counter--;
  2480. attempts.setText(Integer.toString(attempt_counter));
  2481. if(attempt_counter == 0){
  2482. login_btn.setEnabled(false);
  2483. }
  2484. }
  2485.  
  2486. }
  2487. }
  2488. );
  2489. }
  2490.  
  2491. @Override
  2492. public boolean onCreateOptionsMenu(Menu menu) {
  2493. // Inflate the menu; this adds items to the action bar if it is present.
  2494. getMenuInflater().inflate(R.menu.menu_login, menu);
  2495. return true;
  2496. }
  2497.  
  2498. @Override
  2499. public boolean onOptionsItemSelected(MenuItem item) {
  2500. // Handle action bar item clicks here. The action bar will
  2501. // automatically handle clicks on the Home/Up button, so long
  2502. // as you specify a parent activity in AndroidManifest.xml.
  2503. int id = item.getItemId();
  2504.  
  2505. //noinspection SimplifiableIfStatement
  2506. if (id == R.id.action_settings) {
  2507. return true;
  2508. }
  2509.  
  2510. return super.onOptionsItemSelected(item);
  2511. }
  2512. }package com.example.programmingknowledge.simpleloginapp;
  2513.  
  2514. import android.content.Intent;
  2515. import android.support.v7.app.ActionBarActivity;
  2516. import android.os.Bundle;
  2517. import android.view.Menu;
  2518. import android.view.MenuItem;
  2519. import android.view.View;
  2520. import android.widget.Button;
  2521. import android.widget.EditText;
  2522. import android.widget.TextView;
  2523. import android.widget.Toast;
  2524.  
  2525.  
  2526. public class Login extends ActionBarActivity {
  2527. private static EditText username;
  2528. private static EditText password;
  2529. private static TextView attempts;
  2530. private static Button login_btn;
  2531. int attempt_counter = 5;
  2532. @Override
  2533. protected void onCreate(Bundle savedInstanceState) {
  2534. super.onCreate(savedInstanceState);
  2535. setContentView(R.layout.activity_login);
  2536. LoginButton();
  2537. }
  2538.  
  2539. public void LoginButton() {
  2540. username = (EditText)findViewById(R.id.editText_user);
  2541. password = (EditText)findViewById(R.id.editText_password);
  2542. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2543. login_btn = (Button)findViewById(R.id.button_login);
  2544.  
  2545. attempts.setText(Integer.toString(attempt_counter));
  2546.  
  2547. login_btn.setOnClickListener(
  2548. new View.OnClickListener() {
  2549. @Override
  2550. public void onClick(View v) {
  2551. if(username.getText().toString().equals("user") &&
  2552. password.getText().toString().equals("pass") ) {
  2553. Toast.makeText(Login.this,"User and Password is correct",
  2554. Toast.LENGTH_SHORT).show();
  2555. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2556. startActivity(intent);
  2557. } else {
  2558. Toast.makeText(Login.this,"User and Password is not correct",
  2559. Toast.LENGTH_SHORT).show();
  2560. attempt_counter--;
  2561. attempts.setText(Integer.toString(attempt_counter));
  2562. if(attempt_counter == 0){
  2563. login_btn.setEnabled(false);
  2564. }
  2565. }
  2566.  
  2567. }
  2568. }
  2569. );
  2570. }
  2571.  
  2572. @Override
  2573. public boolean onCreateOptionsMenu(Menu menu) {
  2574. // Inflate the menu; this adds items to the action bar if it is present.
  2575. getMenuInflater().inflate(R.menu.menu_login, menu);
  2576. return true;
  2577. }
  2578.  
  2579. @Override
  2580. public boolean onOptionsItemSelected(MenuItem item) {
  2581. // Handle action bar item clicks here. The action bar will
  2582. // automatically handle clicks on the Home/Up button, so long
  2583. // as you specify a parent activity in AndroidManifest.xml.
  2584. int id = item.getItemId();
  2585.  
  2586. //noinspection SimplifiableIfStatement
  2587. if (id == R.id.action_settings) {
  2588. return true;
  2589. }
  2590.  
  2591. return super.onOptionsItemSelected(item);
  2592. }
  2593. }package com.example.programmingknowledge.simpleloginapp;
  2594.  
  2595. import android.content.Intent;
  2596. import android.support.v7.app.ActionBarActivity;
  2597. import android.os.Bundle;
  2598. import android.view.Menu;
  2599. import android.view.MenuItem;
  2600. import android.view.View;
  2601. import android.widget.Button;
  2602. import android.widget.EditText;
  2603. import android.widget.TextView;
  2604. import android.widget.Toast;
  2605.  
  2606.  
  2607. public class Login extends ActionBarActivity {
  2608. private static EditText username;
  2609. private static EditText password;
  2610. private static TextView attempts;
  2611. private static Button login_btn;
  2612. int attempt_counter = 5;
  2613. @Override
  2614. protected void onCreate(Bundle savedInstanceState) {
  2615. super.onCreate(savedInstanceState);
  2616. setContentView(R.layout.activity_login);
  2617. LoginButton();
  2618. }
  2619.  
  2620. public void LoginButton() {
  2621. username = (EditText)findViewById(R.id.editText_user);
  2622. password = (EditText)findViewById(R.id.editText_password);
  2623. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2624. login_btn = (Button)findViewById(R.id.button_login);
  2625.  
  2626. attempts.setText(Integer.toString(attempt_counter));
  2627.  
  2628. login_btn.setOnClickListener(
  2629. new View.OnClickListener() {
  2630. @Override
  2631. public void onClick(View v) {
  2632. if(username.getText().toString().equals("user") &&
  2633. password.getText().toString().equals("pass") ) {
  2634. Toast.makeText(Login.this,"User and Password is correct",
  2635. Toast.LENGTH_SHORT).show();
  2636. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2637. startActivity(intent);
  2638. } else {
  2639. Toast.makeText(Login.this,"User and Password is not correct",
  2640. Toast.LENGTH_SHORT).show();
  2641. attempt_counter--;
  2642. attempts.setText(Integer.toString(attempt_counter));
  2643. if(attempt_counter == 0){
  2644. login_btn.setEnabled(false);
  2645. }
  2646. }
  2647.  
  2648. }
  2649. }
  2650. );
  2651. }
  2652.  
  2653. @Override
  2654. public boolean onCreateOptionsMenu(Menu menu) {
  2655. // Inflate the menu; this adds items to the action bar if it is present.
  2656. getMenuInflater().inflate(R.menu.menu_login, menu);
  2657. return true;
  2658. }
  2659.  
  2660. @Override
  2661. public boolean onOptionsItemSelected(MenuItem item) {
  2662. // Handle action bar item clicks here. The action bar will
  2663. // automatically handle clicks on the Home/Up button, so long
  2664. // as you specify a parent activity in AndroidManifest.xml.
  2665. int id = item.getItemId();
  2666.  
  2667. //noinspection SimplifiableIfStatement
  2668. if (id == R.id.action_settings) {
  2669. return true;
  2670. }
  2671.  
  2672. return super.onOptionsItemSelected(item);
  2673. }
  2674. }package com.example.programmingknowledge.simpleloginapp;
  2675.  
  2676. import android.content.Intent;
  2677. import android.support.v7.app.ActionBarActivity;
  2678. import android.os.Bundle;
  2679. import android.view.Menu;
  2680. import android.view.MenuItem;
  2681. import android.view.View;
  2682. import android.widget.Button;
  2683. import android.widget.EditText;
  2684. import android.widget.TextView;
  2685. import android.widget.Toast;
  2686.  
  2687.  
  2688. public class Login extends ActionBarActivity {
  2689. private static EditText username;
  2690. private static EditText password;
  2691. private static TextView attempts;
  2692. private static Button login_btn;
  2693. int attempt_counter = 5;
  2694. @Override
  2695. protected void onCreate(Bundle savedInstanceState) {
  2696. super.onCreate(savedInstanceState);
  2697. setContentView(R.layout.activity_login);
  2698. LoginButton();
  2699. }
  2700.  
  2701. public void LoginButton() {
  2702. username = (EditText)findViewById(R.id.editText_user);
  2703. password = (EditText)findViewById(R.id.editText_password);
  2704. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2705. login_btn = (Button)findViewById(R.id.button_login);
  2706.  
  2707. attempts.setText(Integer.toString(attempt_counter));
  2708.  
  2709. login_btn.setOnClickListener(
  2710. new View.OnClickListener() {
  2711. @Override
  2712. public void onClick(View v) {
  2713. if(username.getText().toString().equals("user") &&
  2714. password.getText().toString().equals("pass") ) {
  2715. Toast.makeText(Login.this,"User and Password is correct",
  2716. Toast.LENGTH_SHORT).show();
  2717. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2718. startActivity(intent);
  2719. } else {
  2720. Toast.makeText(Login.this,"User and Password is not correct",
  2721. Toast.LENGTH_SHORT).show();
  2722. attempt_counter--;
  2723. attempts.setText(Integer.toString(attempt_counter));
  2724. if(attempt_counter == 0){
  2725. login_btn.setEnabled(false);
  2726. }
  2727. }
  2728.  
  2729. }
  2730. }
  2731. );
  2732. }
  2733.  
  2734. @Override
  2735. public boolean onCreateOptionsMenu(Menu menu) {
  2736. // Inflate the menu; this adds items to the action bar if it is present.
  2737. getMenuInflater().inflate(R.menu.menu_login, menu);
  2738. return true;
  2739. }
  2740.  
  2741. @Override
  2742. public boolean onOptionsItemSelected(MenuItem item) {
  2743. // Handle action bar item clicks here. The action bar will
  2744. // automatically handle clicks on the Home/Up button, so long
  2745. // as you specify a parent activity in AndroidManifest.xml.
  2746. int id = item.getItemId();
  2747.  
  2748. //noinspection SimplifiableIfStatement
  2749. if (id == R.id.action_settings) {
  2750. return true;
  2751. }
  2752.  
  2753. return super.onOptionsItemSelected(item);
  2754. }
  2755. }package com.example.programmingknowledge.simpleloginapp;
  2756.  
  2757. import android.content.Intent;
  2758. import android.support.v7.app.ActionBarActivity;
  2759. import android.os.Bundle;
  2760. import android.view.Menu;
  2761. import android.view.MenuItem;
  2762. import android.view.View;
  2763. import android.widget.Button;
  2764. import android.widget.EditText;
  2765. import android.widget.TextView;
  2766. import android.widget.Toast;
  2767.  
  2768.  
  2769. public class Login extends ActionBarActivity {
  2770. private static EditText username;
  2771. private static EditText password;
  2772. private static TextView attempts;
  2773. private static Button login_btn;
  2774. int attempt_counter = 5;
  2775. @Override
  2776. protected void onCreate(Bundle savedInstanceState) {
  2777. super.onCreate(savedInstanceState);
  2778. setContentView(R.layout.activity_login);
  2779. LoginButton();
  2780. }
  2781.  
  2782. public void LoginButton() {
  2783. username = (EditText)findViewById(R.id.editText_user);
  2784. password = (EditText)findViewById(R.id.editText_password);
  2785. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2786. login_btn = (Button)findViewById(R.id.button_login);
  2787.  
  2788. attempts.setText(Integer.toString(attempt_counter));
  2789.  
  2790. login_btn.setOnClickListener(
  2791. new View.OnClickListener() {
  2792. @Override
  2793. public void onClick(View v) {
  2794. if(username.getText().toString().equals("user") &&
  2795. password.getText().toString().equals("pass") ) {
  2796. Toast.makeText(Login.this,"User and Password is correct",
  2797. Toast.LENGTH_SHORT).show();
  2798. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2799. startActivity(intent);
  2800. } else {
  2801. Toast.makeText(Login.this,"User and Password is not correct",
  2802. Toast.LENGTH_SHORT).show();
  2803. attempt_counter--;
  2804. attempts.setText(Integer.toString(attempt_counter));
  2805. if(attempt_counter == 0){
  2806. login_btn.setEnabled(false);
  2807. }
  2808. }
  2809.  
  2810. }
  2811. }
  2812. );
  2813. }
  2814.  
  2815. @Override
  2816. public boolean onCreateOptionsMenu(Menu menu) {
  2817. // Inflate the menu; this adds items to the action bar if it is present.
  2818. getMenuInflater().inflate(R.menu.menu_login, menu);
  2819. return true;
  2820. }
  2821.  
  2822. @Override
  2823. public boolean onOptionsItemSelected(MenuItem item) {
  2824. // Handle action bar item clicks here. The action bar will
  2825. // automatically handle clicks on the Home/Up button, so long
  2826. // as you specify a parent activity in AndroidManifest.xml.
  2827. int id = item.getItemId();
  2828.  
  2829. //noinspection SimplifiableIfStatement
  2830. if (id == R.id.action_settings) {
  2831. return true;
  2832. }
  2833.  
  2834. return super.onOptionsItemSelected(item);
  2835. }
  2836. }package com.example.programmingknowledge.simpleloginapp;
  2837.  
  2838. import android.content.Intent;
  2839. import android.support.v7.app.ActionBarActivity;
  2840. import android.os.Bundle;
  2841. import android.view.Menu;
  2842. import android.view.MenuItem;
  2843. import android.view.View;
  2844. import android.widget.Button;
  2845. import android.widget.EditText;
  2846. import android.widget.TextView;
  2847. import android.widget.Toast;
  2848.  
  2849.  
  2850. public class Login extends ActionBarActivity {
  2851. private static EditText username;
  2852. private static EditText password;
  2853. private static TextView attempts;
  2854. private static Button login_btn;
  2855. int attempt_counter = 5;
  2856. @Override
  2857. protected void onCreate(Bundle savedInstanceState) {
  2858. super.onCreate(savedInstanceState);
  2859. setContentView(R.layout.activity_login);
  2860. LoginButton();
  2861. }
  2862.  
  2863. public void LoginButton() {
  2864. username = (EditText)findViewById(R.id.editText_user);
  2865. password = (EditText)findViewById(R.id.editText_password);
  2866. attempts = (TextView)findViewById(R.id.textView_attemt_Count);
  2867. login_btn = (Button)findViewById(R.id.button_login);
  2868.  
  2869. attempts.setText(Integer.toString(attempt_counter));
  2870.  
  2871. login_btn.setOnClickListener(
  2872. new View.OnClickListener() {
  2873. @Override
  2874. public void onClick(View v) {
  2875. if(username.getText().toString().equals("user") &&
  2876. password.getText().toString().equals("pass") ) {
  2877. Toast.makeText(Login.this,"User and Password is correct",
  2878. Toast.LENGTH_SHORT).show();
  2879. Intent intent = new Intent("com.example.programmingknowledge.simpleloginapp.User");
  2880. startActivity(intent);
  2881. } else {
  2882. Toast.makeText(Login.this,"User and Password is not correct",
  2883. Toast.LENGTH_SHORT).show();
  2884. attempt_counter--;
  2885. attempts.setText(Integer.toString(attempt_counter));
  2886. if(attempt_counter == 0){
  2887. login_btn.setEnabled(false);
  2888. }
  2889. }
  2890.  
  2891. }
  2892. }
  2893. );
  2894. }
  2895.  
  2896. @Override
  2897. public boolean onCreateOptionsMenu(Menu menu) {
  2898. // Inflate the menu; this adds items to the action bar if it is present.
  2899. getMenuInflater().inflate(R.menu.menu_login, menu);
  2900. return true;
  2901. }
  2902.  
  2903. @Override
  2904. public boolean onOptionsItemSelected(MenuItem item) {
  2905. // Handle action bar item clicks here. The action bar will
  2906. // automatically handle clicks on the Home/Up button, so long
  2907. // as you specify a parent activity in AndroidManifest.xml.
  2908. int id = item.getItemId();
  2909.  
  2910. //noinspection SimplifiableIfStatement
  2911. if (id == R.id.action_settings) {
  2912. return true;
  2913. }
  2914.  
  2915. return super.onOptionsItemSelected(item);
  2916. }
  2917. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement