在ListView Android中编辑文本重复值

时间:2017-08-15 11:32:05

标签: android listview

我是android新手。我想在listview中添加编辑文本,但是有重复的值。

例如,当我按下索引1的编辑文本时,它还会关注编辑文本索引4。

我的代码如下。

在Asynctask里面:

        if(jsonString!=null){
            try{
                JSONArray orderDetails = new JSONArray(jsonString);

                for(int i = 0 ; i<orderDetails.length();i++){
                    JSONObject p = orderDetails.getJSONObject(i);
                    String productCode = p.getString("ProductCode");
                    String orderCodeDetail = p.getString("Code");
                    Integer orderQuantity = p.getInt("Quantity");
                    for (int x = 0; x < orderQuantity; x++) {

                    String filterProductUrl = ""+baseUrl+"Products?filter={\"where\":{\"Code\":\""+productCode+"\"}}";
                    HttpHandler sh2 = new HttpHandler();
                    String jsonStr2 = sh2.makeServiceCall(filterProductUrl);

                    if(jsonStr2 != null){

                        try {
                                JSONArray productDetails = new JSONArray(jsonStr2);
                                for (int j = 0; j < productDetails.length(); j++) {

                                    JSONObject q = productDetails.getJSONObject(j);
                                    productName = q.getString("Name");
                                    productImage = q.getString("Image");
                                    String encodeImage = productImage.replace("data:image/jpeg;base64,", "").replace("data:image/png;base64,", "");
                                    byte[] decodedString = Base64.decode(encodeImage, Base64.DEFAULT);
                                        base64Bitmap = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
                                    itemCount = itemCount +1;


                                        HashMap<String, Object> productData = new HashMap<String, Object>();
                                        productData.put("orderQuantity",orderQuantity);
                                        productData.put("productName", productName);
                                        productData.put("base64Bitmap", base64Bitmap);
                                        productData.put("orderCodeDetail", orderCodeDetail);
                                        orderDetailList.add(productData);
.....

我的适配器:

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        return this.createViewFromResource(position, convertView, parent, layout);
}

private View createViewFromResource(int position, View convertView,
                                    ViewGroup parent, int resource) {
    View v;
    if (convertView == null) {
        v = mInflater.inflate(resource, parent, false);
    } else {
        v = convertView;
    }

    this.bindView(position, v);

    return v;
}

0 个答案:

没有答案