我有一个自定义列表视图,每个项目都包含EditText。我需要为EditText使用getText()。 以下是代码的一部分:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
detailList2 = db.getAllInventoryItem();
ViewHolder holder;
final int _position = position;
if (convertView == null) {
convertView = l_Inflater.inflate(R.layout.activity_today_sales_list_view, null);
holder = new ViewHolder();
holder.txt_itemName = (TextView) convertView.findViewById(R.id.itemNameTB);
holder.txt_itemPrice = (TextView) convertView.findViewById(R.id.priceTB);
holder.txt_itemQuantity = (TextView) convertView.findViewById(R.id.quantityTB);
holder.txt_plusBtn = (Button) convertView.findViewById(R.id.addBtn);
holder.txt_minusBtn = (Button) convertView.findViewById(R.id.minusBtn);
holder.txt_salesPrice = (EditText) convertView.findViewById(R.id.price);
holder.txt_plusBtn.setTag(holder);
holder.txt_minusBtn.setTag(holder);
holder.txt_salesPrice.setId(_position);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.txt_itemName.setText(itemDetailsrrayList.get(position).getItemName());
holder.txt_itemPrice.setText("RM "+itemDetailsrrayList.get(position).getItemCost());
holder.txt_salesPrice.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
}
});
return convertView;
}
如果我使用setOnFoucsChangeListener或我将使用其他监听器,这样可以吗? 请帮助。谢谢!