我创建了这个小程序,允许用户在 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()));
}
}
}