package com.jmedved.example.android.dice;

import java.util.Random;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class MainActivity extends Activity {

	private static TextView textNumber;
	private static Random Rnd = new Random(); 
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        textNumber = (TextView)findViewById(R.id.textNumber);
        ((Button)findViewById(R.id.buttonThrow)).setOnClickListener(buttonThrow_OnClickListener);
        
        buttonThrow_OnClickListener.onClick(null);
    }
    
	private static View.OnClickListener buttonThrow_OnClickListener =  new View.OnClickListener() {
	    public void onClick(View view) {
	    	int n = 1 + Rnd.nextInt(6);
	    	textNumber.setText(Integer.toString(n));
	    }
	};

}