自定义列表视图中的Android EditText getText()

时间:2013-05-14 23:36:11

标签: android android-listview

我有一个自定义列表视图,每个项目都包含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或我将使用其他监听器,这样可以吗? 请帮助。谢谢!

0 个答案:

没有答案