Button 即时更新按钮上的文本

Button 即时更新按钮上的文本,button,insert-update,Button,Insert Update,我无法立即更新按钮上的文本。它总是在后面更新一个输入。插入数据时获得即时结果的最佳方法是什么 public void getTenPercent(){ Cursor res = myDb.getAllData(); double tithe = 0.00; while(res.moveToNext()){ if(!res.getString(1).equals("")) tithe += Double.parseDouble(res

我无法立即更新按钮上的文本。它总是在后面更新一个输入。插入数据时获得即时结果的最佳方法是什么

public void getTenPercent(){
    Cursor res = myDb.getAllData();
    double tithe = 0.00;
    while(res.moveToNext()){
        if(!res.getString(1).equals(""))
            tithe += Double.parseDouble(res.getString(1)) / 10;
    }
    btnDelete = (Button) findViewById(R.id.btn_delete);
    btnDelete.setText("$" + String.valueOf(tithe));
    res.close();
}
无论我在何处尝试实现getTenPercent(),在它之前、之后,甚至在它之前和之后,它都会在一个输入之后更新它