如何在Listview中获取edittext的位置
How to get edittext position in Listview
我正在研究 ListView
EditText
inside.I 在 ListView
的每个项目中使用了四个 EditText
。我在获取EditText
在 ListView
中的位置。下面是我的代码。我能够获取 TextView
的位置,但是在获取 EditText
的位置时我遇到了问题。
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
myproductpercarton = (TextView) view.findViewById(R.id.txtorderamount);
final String ssss =(String) ((TextView) view.findViewById(R.id.txtorderamount)).getText();
mytotalprice = (TextView) view.findViewById(R.id.txtprice);
mm = (CheckBox) view.findViewById(R.id.mycheck);
mm.setFocusableInTouchMode(true);
mm.setFocusable(true);
mm2 = (CheckBox) view.findViewById(R.id.mynewcheck);
mm2.setFocusableInTouchMode(true);
mm2.setFocusable(true);
myorderprice = (EditText) view.findViewById(R.id.txtorderby);
myorderprice.setFocusableInTouchMode(true);
myorderprice.setFocusable(true);
mycartonno = (EditText) view.findViewById(R.id.txtordercarton);
mycartonno.setFocusableInTouchMode(true);
mycartonno.setFocusable(true);
myproductno = (EditText) view.findViewById(R.id.txtproduct);
myproductno.setFocusableInTouchMode(true);
myproductno.setFocusable(true);
myproductno.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String myprodpercart;
map = (HashMap<String, String>) getListView().getItemAtPosition(position);
HashMap<String, String> map2 = (HashMap<String, String>) getListView().getItemAtPosition(position);
HashMap<String, String> map3 = (HashMap<String, String>) getListView().getItemAtPosition(position);
double orderId4;
double mycarton2;
double mynewcart;
double myprodno2;
double mycartquantity;
double mytotal;
String mynoocarton;
double mynoocarton44;
int myprodno3;
String temp=mycartonno.getText().toString();
String contents = mycartonno.getText().toString();
orderId4 = new Double(map.get(TAG_PRODUCTPERCARTON));
Log.d("MyOrderId :: ", String.valueOf(orderId4));
mycartonprice2 = map.get(TAG_PRODUCTPERCARTON2);
Log.d("MyCartonPrice :: ", String.valueOf(mycartonprice2));
mynoocarton = mycartonno.getText().toString();
mynoocarton44 = new Double(mycartonno.getText().toString());
mycarton2 = new Double(mynoocarton);
mynewcart = new Double(mycartonprice2);
myprodno2 = new Double(orderId4 * mycarton2);
myprodno3 = new Integer((int) myprodno2);
mycartquantity = new Double(mycartonno.getText().toString());
Log.d("MyCartonNo :: ", mycartonno.getText().toString());
Log.d("MyCartonNo2 :: ",contents);
mytotal = new Double(mycartquantity * mynewcart);
String mynoocarton3 = String.valueOf(mynoocarton44);
String total = String.valueOf(mytotal);
String mm = String.valueOf(myprodno3);
mycartonno.setText(mynoocarton3);
myproductno.setText(mm);
mytotalprice.setText(total);
Toast.makeText(getActivity(), ssss + " " + mynewcart + "----" + mm + " " + total,
Toast.LENGTH_SHORT).show();
}
});
mydiscount = (EditText) view.findViewById(R.id.txtdiscount);
mydiscount.setFocusableInTouchMode(true);
mydiscount.setFocusable(true);
}
});
我自己解决了这个问题,现在工作正常。我刚在 setOnClickListener
里面拿了另一个 textview
和两个新的 edittext
。我刚刚在 setOnClickListener
中添加了以下代码。
TextView mynewtotal = (TextView) view.findViewById(R.id.txtprice);
EditText mycartonprod = (EditText) view.findViewById(R.id.txtordercarton);
mycartonprod.setFocusableInTouchMode(true);
mycartonprod.setFocusable(true);
EditText myprod = (EditText) view.findViewById(R.id.txtproduct);
myprod.setFocusableInTouchMode(true);
myprod.setFocusable(true);
我正在研究 ListView
EditText
inside.I 在 ListView
的每个项目中使用了四个 EditText
。我在获取EditText
在 ListView
中的位置。下面是我的代码。我能够获取 TextView
的位置,但是在获取 EditText
的位置时我遇到了问题。
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
myproductpercarton = (TextView) view.findViewById(R.id.txtorderamount);
final String ssss =(String) ((TextView) view.findViewById(R.id.txtorderamount)).getText();
mytotalprice = (TextView) view.findViewById(R.id.txtprice);
mm = (CheckBox) view.findViewById(R.id.mycheck);
mm.setFocusableInTouchMode(true);
mm.setFocusable(true);
mm2 = (CheckBox) view.findViewById(R.id.mynewcheck);
mm2.setFocusableInTouchMode(true);
mm2.setFocusable(true);
myorderprice = (EditText) view.findViewById(R.id.txtorderby);
myorderprice.setFocusableInTouchMode(true);
myorderprice.setFocusable(true);
mycartonno = (EditText) view.findViewById(R.id.txtordercarton);
mycartonno.setFocusableInTouchMode(true);
mycartonno.setFocusable(true);
myproductno = (EditText) view.findViewById(R.id.txtproduct);
myproductno.setFocusableInTouchMode(true);
myproductno.setFocusable(true);
myproductno.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String myprodpercart;
map = (HashMap<String, String>) getListView().getItemAtPosition(position);
HashMap<String, String> map2 = (HashMap<String, String>) getListView().getItemAtPosition(position);
HashMap<String, String> map3 = (HashMap<String, String>) getListView().getItemAtPosition(position);
double orderId4;
double mycarton2;
double mynewcart;
double myprodno2;
double mycartquantity;
double mytotal;
String mynoocarton;
double mynoocarton44;
int myprodno3;
String temp=mycartonno.getText().toString();
String contents = mycartonno.getText().toString();
orderId4 = new Double(map.get(TAG_PRODUCTPERCARTON));
Log.d("MyOrderId :: ", String.valueOf(orderId4));
mycartonprice2 = map.get(TAG_PRODUCTPERCARTON2);
Log.d("MyCartonPrice :: ", String.valueOf(mycartonprice2));
mynoocarton = mycartonno.getText().toString();
mynoocarton44 = new Double(mycartonno.getText().toString());
mycarton2 = new Double(mynoocarton);
mynewcart = new Double(mycartonprice2);
myprodno2 = new Double(orderId4 * mycarton2);
myprodno3 = new Integer((int) myprodno2);
mycartquantity = new Double(mycartonno.getText().toString());
Log.d("MyCartonNo :: ", mycartonno.getText().toString());
Log.d("MyCartonNo2 :: ",contents);
mytotal = new Double(mycartquantity * mynewcart);
String mynoocarton3 = String.valueOf(mynoocarton44);
String total = String.valueOf(mytotal);
String mm = String.valueOf(myprodno3);
mycartonno.setText(mynoocarton3);
myproductno.setText(mm);
mytotalprice.setText(total);
Toast.makeText(getActivity(), ssss + " " + mynewcart + "----" + mm + " " + total,
Toast.LENGTH_SHORT).show();
}
});
mydiscount = (EditText) view.findViewById(R.id.txtdiscount);
mydiscount.setFocusableInTouchMode(true);
mydiscount.setFocusable(true);
}
});
我自己解决了这个问题,现在工作正常。我刚在 setOnClickListener
里面拿了另一个 textview
和两个新的 edittext
。我刚刚在 setOnClickListener
中添加了以下代码。
TextView mynewtotal = (TextView) view.findViewById(R.id.txtprice);
EditText mycartonprod = (EditText) view.findViewById(R.id.txtordercarton);
mycartonprod.setFocusableInTouchMode(true);
mycartonprod.setFocusable(true);
EditText myprod = (EditText) view.findViewById(R.id.txtproduct);
myprod.setFocusableInTouchMode(true);
myprod.setFocusable(true);