私はTextWatcher
を使用して入力したテキストを取得したいと思います。Android EditText:入力したテキストを取得する
いくつかの問題があります。
たとえば、32.5と入力します。その方法では、私はSET<Product>
に追加したいです。
ここで各&後、私は避けたい...
を追加することも、その後2を追加し、SETに3そのアドオン製品のオブジェクトを入力してください意味object.Thatあらゆる数の節約。私はEditText
を入力し終えたら、次にそれを取るしたい:
final EditText txtQty = new EditText(this);
txtQty.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
Log.v("TAG", "afterTextChanged" + s.toString());
String enterdPrice = txtPrice.getText().toString();
double remainQty =0.00;
Product enterdProduct = new Product();
try{
String enteredQty = s.toString();
enterdProduct.setProductCode(txtCode.getText().toString());
enterdProduct.setPrice(Double.parseDouble(enterdPrice));
//enterdProduct.setQty(Double.parseDouble(enteredQty));
// TO-DO
if (productSet.contains(enterdProduct)) {
productSet.remove(enterdProduct);
}
productSet.add(enterdProduct);
System.out.println("SIZE --" + productSet.size());
}
catch (Exception e) {
e.printStackTrace();
}
});
は私のアイデアを与えてください、私たちはかつてのEditTextを取得し、私はテキストをenetred入力することができますどのように?
必ずしもENTERが押されているとは限りません。フォーカスを別のフィールドに切り替えることもできます。 –