Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Android 3.1, trouble displaying two counters side by side
- import android.app.Activity;
- import android.os.Bundle;
- import android.content.Intent;
- import android.widget.Button;
- import android.widget.EditText;
- import android.view.View;
- import android.view.View.OnClickListener;
- public class swim2 extends Activity {
- // References to UI views
- EditText txtCount;
- EditText txtCount2;
- Button PUp;
- Button NUp;
- static int Count = 0; // Initial count
- static int Count2 = 0;
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main3);
- // TODO Auto-generated method stub
- Button previous = (Button) findViewById(R.id.button4);
- previous.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- Intent myIntent = new Intent(view.getContext(), swim1.class);
- startActivityForResult(myIntent, 0);
- }
- });
- // Retrieve references to UI views by their id in XML layout
- NUp = (Button)findViewById(R.id.incremintationbutton2);
- txtCount2 = (EditText)findViewById(R.id.ni);
- txtCount2.setText(String.valueOf(Count2)); //Set initial value
- NUp = (Button)findViewById(R.id.incremintationbutton2);
- // Process the button on-click event
- NUp.setOnClickListener(new OnClickListener() {
- public void onClick(View Button) {
- Count++;
- txtCount2.setText(String.valueOf(Count2));
- }
- });
- PUp = (Button)findViewById(R.id.incremintationbutton1);
- txtCount = (EditText)findViewById(R.id.pi);
- txtCount.setText(String.valueOf(Count)); // Set initial value
- PUp = (Button)findViewById(R.id.incremintationbutton1);
- PUp.setOnClickListener(new OnClickListener() {
- public void onClick(View Button) {
- Count++;
- txtCount.setText(String.valueOf(Count));
- }
- });
- }
- }
Add Comment
Please, Sign In to add comment