0

我在每个项目中都有一个带有 EditText 的自定义列表视图。我需要为 EditText 获取文本()。这是代码的一部分:

@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 或者我应该使用其他监听器可以吗?请帮忙。谢谢 !

4

0 回答 0