0

ユーザーが EditText に数値を入力できるようにするこの小さなプログラムを作成しました。

  • 初めてボタンをクリックすると、アプリはそれを TextView に表示する必要があります
  • その後、以前の値よりも大きい場合にのみ、新しい値を保存する必要があります

お願い助けて。

public class BidActivity extends Activity implements OnClickListener {
    public TextView tt;
    public EditText textbo;
    public String total;
    public Button btnnn;
    public Double protein;
    double price = 0;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        textbo = (EditText)findViewById(R.id.txtbid);
        tt = (TextView)findViewById(R.id.textView1);

        btnnn = (Button)findViewById(R.id.btnbit);
        btnnn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        String total = textbo.getText().toString();
        price = Double.parseDouble(textbo.getText().toString());

        //tt.setText("double: "+price);
        if(Double.parseDouble(textbo.getText().toString()) < price){
            tt.setText("double: "+price);
        }else{
            tt.setText("double: "+Double.parseDouble(textbo.getText().toString()));
        }   
    }
}
4

1 に答える 1