Android Form Reset?

后端 未结 3 1393
半阙折子戏
半阙折子戏 2021-01-26 22:16

I have a simple calculator that has six EditText views where users will enter numbers to perform a simple math function. This app will satisfy a repetitive task wherein the user

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-26 22:40

    No, you have to implement it yourself. I suggest you create an int array with the IDs of all your EditTexts you want to reset (R.id.xyz). Then create a loop to .setText() to each of the EditTexts from the array, which you can call every time you want the fields to be cleared. Something like:

    private void resetFields() {
        EditText temp;
    
            for (int i = 0; i < myEditTexts.length; i++) {
                temp = (EditText) findViewById(textViews[i]);
            temp.setText("");
        }
    }
    

提交回复
热议问题