package com.android.example;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends Activity implements OnClickListener {

	// private Button connectPhones;
	// private String serverIpAddress = "";
	// private boolean connected = false;
	// private Handler handler = new Handler();

	private final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT;
	private int count1;
	private int count2;
	private Button button1;
	private Button button2;

	// LinearLayout liLayout;
	// EditText editText;
	// Button button;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		count1 = 0;
		count2 = 0;

		LinearLayout linearLayout = new LinearLayout(this);
		linearLayout.setOrientation(LinearLayout.HORIZONTAL);

		setContentView(R.layout.activity_main);

		// TextView tv = new TextView(this);
		// tv.setText("Hello, World");
		// connectPhones = (Button) findViewById(@+id/button1);
		// connectPhones.setOnClickListener(connectListener);

		button1 = new Button(this);
		button1.setText("Count");
		button1.setOnClickListener(this);
		linearLayout.addView(button1, new LinearLayout.LayoutParams(
				WRAP_CONTENT, WRAP_CONTENT));

		button2 = new Button(this);
		button2.setText("Count");
		button2.setOnClickListener(this);
		linearLayout.addView(button2, new LinearLayout.LayoutParams(
				WRAP_CONTENT, WRAP_CONTENT));

	}

	public void onClick(View v) {
		if (v == button1) {
			count1++;
			button1.setText("Count:" + count1);
		} else if (v == button2) {
			count2++;
			button2.setText("Count:" + count2);
		}
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
