动态计算一个链接到一系列按钮的TextView

Dynamic calculation of a TextView that is linked to a seris of buttons

本文关键字:一系列 按钮 TextView 链接 一个 计算 动态      更新时间:2023-09-26

我试图在我正在构建的应用程序上创建此流。我有一点麻烦得到TextView是友好的任何类型的公式/条件。任何建议我如何能得到TextView通过我的文本观察者动态输出的结果?提前感谢!

文本视图
    //------------------DISPLAY-----------------''
    netsale = (TextView)findViewById(R.id.netsale_input);
    //--------------WAIT ASSISTANT--------------''
    waMain = (TextView)findViewById(R.id.txt_wa_main);
    waSplit = (TextView)findViewById(R.id.txt_wa_split);

清晰的按钮

public void clr_Clicked(View sender){
        netsale.setText("0");
        isempty=true;
    }

数字小键盘

static boolean isempty=true;
public void num_Clicked(View sender){   
    Button bt=(Button)sender;
    if(netsale.getText().length()>5)return;
    if(isempty)
        {
            if(bt.getText().toString().equals("0"))return;
            netsale.setText(bt.getText());
            isempty=false;
        }
    else
        {
            netsale.append(bt.getText());
        }
}

文本观察家

 private TextWatcher filterTextWatcher = new TextWatcher() {    
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
    }
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }
    @Override
    public void afterTextChanged(Editable s) {
    }
}

当你点击一个按钮时,比如"7",你应该通过使用setText(CharSequence);

将该值附加到TextView中

所以一开始如果你的TextView是空白的("),当你点击7,它应该导致你的TextView显示"7"