Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. package com.example.palmitessa;
  2.  
  3. import androidx.annotation.NonNull;
  4. import androidx.appcompat.app.AppCompatActivity;
  5.  
  6. import android.os.Bundle;
  7.  
  8. import android.util.Log;
  9. import android.view.View;
  10. import android.widget.Button;
  11. import android.widget.EditText;
  12. import android.widget.TextView;
  13.  
  14. public class MainActivity extends AppCompatActivity {
  15. private final String TAG = "Palmitessa.HelloWorld";
  16.  
  17. @Override
  18. protected void onCreate(Bundle savedInstanceState) {
  19. super.onCreate(savedInstanceState);
  20. setContentView(R.layout.activity_main);
  21. final TextView textHW = (TextView)findViewById(R.id.textView);
  22. final Button apply = (Button) findViewById(R.id.button);
  23. final Button clear = (Button) findViewById(R.id.button2);
  24. final EditText edit = (EditText) findViewById(R.id.editText);
  25.  
  26. apply.setOnClickListener(new Button.OnClickListener() {
  27. @Override
  28. public void onClick(View v){
  29. textHW.setText(edit.getText().toString());
  30. }
  31. });
  32. clear.setOnClickListener(new Button.OnClickListener() {
  33. @Override
  34. public void onClick(View v){
  35. textHW.setText(R.string.clearText);
  36. }
  37. });
  38. Log.i(TAG, " -onCreate- Set bottone Apply e Clear");
  39. }
  40.  
  41. @Override
  42. protected void onStart() {
  43. super.onStart();
  44. //...
  45. Log.i(TAG, " -onStart- The activity is visible and about to be started.");
  46. }
  47.  
  48. @Override
  49. protected void onRestart() {
  50. super.onRestart();
  51. //...
  52. Log.i(TAG, " -onRestart- The activity is visible and about to be restarted.");
  53. }
  54.  
  55. @Override
  56. protected void onResume() {
  57. super.onResume();
  58. //...
  59. Log.i(TAG, " -onResume- The activity has focus (it is now \"resumed\")");
  60. }
  61.  
  62. @Override
  63. protected void onPause() {
  64. super.onPause();
  65. Log.i(TAG,
  66. " -onPause- Another activity is taking focus (this activity is about to be \"paused\")");
  67. }
  68.  
  69. @Override
  70. protected void onStop() {
  71. super.onStop();
  72. //...
  73. Log.i(TAG, " -onStop- The activity is no longer visible (it is now \"stopped\")");
  74. }
  75.  
  76. @Override
  77. protected void onDestroy() {
  78. super.onDestroy();
  79. //...
  80. Log.i(TAG, " -onDestroy- The activity is about to be destroyed.");
  81. }
  82.  
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement