Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. package com.example.student.newone;
  2.  
  3. import android.content.Intent;
  4. import android.net.Uri;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.Toast;
  11.  
  12. import com.example.student.newone.actiivity.LoginPage;
  13.  
  14. public class MainActivity extends AppCompatActivity {
  15.  
  16. Button btnLoginPage,btnCamera,btnDial,btnURL;
  17. EditText editText;
  18.  
  19.  
  20. @Override
  21. protected void onCreate(Bundle savedInstanceState) {
  22. super.onCreate(savedInstanceState);
  23. setContentView(R.layout.activity_main);
  24.  
  25. initCompoments();
  26. setComponents();
  27.  
  28.  
  29. }
  30.  
  31. private void initCompoments() {
  32.  
  33. editText = (EditText) findViewById(R.id.edtText);
  34. btnLoginPage = (Button) findViewById(R.id.btnGotoLogin);
  35. btnCamera=(Button)findViewById(R.id.btnCamera);
  36. btnURL=(Button)findViewById(R.id.btnURL);
  37. btnDial=(Button)findViewById(R.id.btnDial);
  38. }
  39.  
  40.  
  41. private void setComponents() {
  42.  
  43. btnLoginPage.setOnClickListener(new View.OnClickListener() {
  44. @Override
  45. public void onClick(View view) {
  46.  
  47.  
  48. Toast.makeText(MainActivity.this, "Click", Toast.LENGTH_SHORT).show();
  49. Intent intent = new Intent(MainActivity.this, LoginPage.class);
  50. intent.putExtra("TAG_NAME",editText.getText().toString());
  51. startActivity(intent);
  52. }
  53. });
  54.  
  55. btnDial.setOnClickListener(v->{
  56.  
  57. Uri uri= Uri.parse("tel:+38971458777");
  58. Intent intent=new Intent(Intent.ACTION_DIAL,uri);
  59.  
  60. if(intent.resolveActivity(getPackageManager())!=null) {
  61. startActivity(intent);
  62. }
  63. });
  64.  
  65.  
  66. btnCamera.setOnClickListener(v->
  67. {
  68. Intent intents=new Intent("android.media.action.IMAGE_CAPTURE");
  69. if(intents.resolveActivity(getPackageManager())!=null) {
  70. startActivity(intents);
  71. }
  72. }
  73.  
  74. );
  75.  
  76. btnURL.setOnClickListener(v->
  77. {
  78. Uri uris=Uri.parse();
  79. Intent int=new Intent(Intent.ACTION_VIEW,uris);
  80. if(int.resolveActivity(getPackageManager())!=null) {
  81. startActivity(int);
  82. }
  83. }
  84.  
  85. );
  86.  
  87. }
  88. }
  89. Login_PAGE
  90. package com.example.student.newone.actiivity;
  91.  
  92. import android.os.Bundle;
  93. import android.support.annotation.Nullable;
  94. import android.support.v7.app.AppCompatActivity;
  95. import android.view.View;
  96. import android.widget.Button;
  97. import android.widget.EditText;
  98. import android.widget.Toast;
  99.  
  100. import com.example.student.newone.MainActivity;
  101. import com.example.student.newone.R;
  102.  
  103. /**
  104. * Created by Student on 2/21/2018.
  105. */
  106.  
  107. public class LoginPage extends AppCompatActivity {
  108.  
  109. Button btn;
  110. EditText edtUserName,edtUserPassword;
  111.  
  112. @Override
  113. protected void onCreate( Bundle savedInstanceState) {
  114. super.onCreate(savedInstanceState);
  115.  
  116. setContentView(R.layout.login_page);
  117.  
  118. initComponents();
  119. setComponents();
  120.  
  121. }
  122.  
  123. private void initComponents()
  124. {
  125.  
  126. edtUserName=(EditText) findViewById(R.id.edtUserName);
  127. edtUserPassword=(EditText)findViewById(R.id.edtUserPassword);
  128. btn=(Button) findViewById(R.id.btnGoBack);
  129.  
  130. }
  131.  
  132.  
  133.  
  134.  
  135. private void setComponents() {
  136. Bundle bundle=getIntent().getExtras();
  137. if(bundle!=null ){
  138. String text=bundle.getString("TAG_NAME");
  139.  
  140. edtUserName.setText(text);
  141. // Toast.makeText(this,text,Toast.LENGTH_SHORT).show();
  142.  
  143.  
  144. btn.setOnClickListener(new View.OnClickListener() {
  145. @Override
  146. public void onClick(View view) {
  147. onBackPressed();
  148. }
  149. });
  150.  
  151.  
  152.  
  153. }
  154.  
  155. }
  156.  
  157. @Override
  158. public void onBackPressed() {
  159. super.onBackPressed();
  160. }
  161.  
  162.  
  163. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement