Guest User

Untitled

a guest
Aug 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. Android 3.1, trouble displaying two counters side by side
  2. import android.app.Activity;
  3. import android.os.Bundle;
  4. import android.content.Intent;
  5. import android.widget.Button;
  6. import android.widget.EditText;
  7. import android.view.View;
  8. import android.view.View.OnClickListener;
  9.  
  10.  
  11.  
  12. public class swim2 extends Activity {
  13.  
  14. // References to UI views
  15. EditText txtCount;
  16. EditText txtCount2;
  17. Button PUp;
  18. Button NUp;
  19.  
  20.  
  21. static int Count = 0; // Initial count
  22. static int Count2 = 0;
  23.  
  24. /** Called when the activity is first created. */
  25. @Override
  26. public void onCreate(Bundle savedInstanceState) {
  27. super.onCreate(savedInstanceState);
  28. super.onCreate(savedInstanceState);
  29. setContentView(R.layout.main3);
  30. // TODO Auto-generated method stub
  31.  
  32.  
  33.  
  34.  
  35. Button previous = (Button) findViewById(R.id.button4);
  36. previous.setOnClickListener(new View.OnClickListener() {
  37. public void onClick(View view) {
  38. Intent myIntent = new Intent(view.getContext(), swim1.class);
  39. startActivityForResult(myIntent, 0);
  40. }
  41.  
  42. });
  43. // Retrieve references to UI views by their id in XML layout
  44. NUp = (Button)findViewById(R.id.incremintationbutton2);
  45. txtCount2 = (EditText)findViewById(R.id.ni);
  46. txtCount2.setText(String.valueOf(Count2)); //Set initial value
  47.  
  48.  
  49. NUp = (Button)findViewById(R.id.incremintationbutton2);
  50. // Process the button on-click event
  51. NUp.setOnClickListener(new OnClickListener() {
  52.  
  53. public void onClick(View Button) {
  54. Count++;
  55. txtCount2.setText(String.valueOf(Count2));
  56. }
  57. });
  58. PUp = (Button)findViewById(R.id.incremintationbutton1);
  59. txtCount = (EditText)findViewById(R.id.pi);
  60. txtCount.setText(String.valueOf(Count)); // Set initial value
  61.  
  62. PUp = (Button)findViewById(R.id.incremintationbutton1);
  63. PUp.setOnClickListener(new OnClickListener() {
  64. public void onClick(View Button) {
  65. Count++;
  66. txtCount.setText(String.valueOf(Count));
  67. }
  68. });
  69.  
  70. }
  71.  
  72. }
Add Comment
Please, Sign In to add comment