1

I am trying to make an android app for my local fence painting business and I simply want it to calculate quotes and payments. My problem is figuring out how to get a simple input box for the square feet of the fence (edittext) with the help of a button to display a that input to a textview. Will you help me?

Also if there is a different way to do this I would love to hear it. Thank you!

4

1 回答 1

0

我的问题是弄清楚如何在按钮的帮助下为栅栏的平方英尺(edittext)获取一个简单的输入框,以将该输入显示到文本视图。

很简单。创建 a TextView、 aButton和一个EditText对象:

TextView txtView;
Button btn;
EditText edtText;

初始化它们:

txtView = (TextView) findViewById(R.id...);
btn = (Button) findViewById(R.id...);
edtText = (EditText) findViewById(R.id...);

这是您EditText通过单击获取输入Button并将输入设置为的方式TextView

btn.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
         String inputText = edtText.getText().toString(); // Get the input
         txtView.setText(inputText); // Set the text to the TextView
    }
});
于 2013-05-22T00:45:16.500 回答