Android Form Reset?

后端 未结 3 1391
半阙折子戏
半阙折子戏 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:35

    The most basic way to do this would be to simply reset your EditText views. If you have logic that drives the update of these fields, then resetting them to an empty String and requesting a "recalculation" to update the hints.

    Something like this:

    private void onClear()
    {
        EditText firstField = (EditText)this.findById(R.id.firstField);
        EditText secondField = (EditText)this.findById(R.id.secondField);
        //...etc...
        if (firstField != null) firstField.setText("");
        if (secondField != null) secondField.setText("");
    
        updateHints();
    }
    
    private void updateHints()
    {
        //Logic for your "hints"
    }
    

提交回复
热议问题