1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.Test;

import android.content.DialogInterface;
import android.os.Bundle;
import android.app.Activity;
import android.text.Editable;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

    private Button button;
    private EditText mEditText;
    private TextView mTextView;
    private int a;
    //private String s;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mEditText = (EditText) findViewById(R.id.editText);
        mTextView= (TextView) findViewById(R.id.textView2);

        //a = Integer.parseInt(mEditText.getText().toString());
        a=Integer.parseInt(mEditText.getText().toString());
        //s = Integer.toString(a);

        button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new MyOnClickListener());
    }

    @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;
    }


    private class MyOnClickListener implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            //mTextView.setText(format(formatter.format(a)));
            //mTextView.setText(s);
            //mTextView.setText(mEditText.getText());
            mTextView.setText(String.valueOf(a));
        }
    }
}