Android:简单的适配器getview方法表现得很奇怪

时间:2014-01-22 08:08:14

标签: android

我有一张表,我将产品的子品牌插入HashMap并将其传递给SimpleAdapter

现在我正在检查我收到的值。下面是logcat。

  

01-22 13:21:45.369:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00008975   01-22 13:21:45.379:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00008975   01-22 13:21:45.379:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00008975   01-22 13:21:45.379:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00000408   01-22 13:21:45.379:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00000408   01-22 13:21:45.379:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00000836   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00000836   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009206   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009206   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009377   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00000836   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009206   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00010000   01-22 13:21:45.389:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00010000   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009684   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009684   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009174   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00010072   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00000838   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009564   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009043   01-22 13:21:45.399:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009371   01-22 13:21:45.409:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00000825   01-22 13:21:45.409:D / subBrandCodeColoring(14653):放入地图(SubbranndCode):00009371   01-22 13:21:45.559:D / subBrandCodeColoring(14653):0:productname $ 01MS.1.VCF 100g * 144 * 10K   01-22 13:21:45.559:D / subBrandCodeColoring(14653):0:subBrandCode 00008975   01-22 13:21:45.579:D / subBrandCodeColoring(14653):1:productname $ 02MS.1.VCF 160g * 72   01-22 13:21:45.579:D / subBrandCodeColoring(14653):1:subBrandCode 00008975   01-22 13:21:45.609:D / subBrandCodeColoring(14653):2:productname $ 02MS.1.VCF 160g * 72 * 16K   01-22 13:21:45.619:D / subBrandCodeColoring(14653):2:subBrandCode 00008975   01-22 13:21:45.639:D / subBrandCodeColoring(14653):3:productname $ 03MS.1.CDC 200gSPI * 72   01-22 13:21:45.639:D / subBrandCodeColoring(14653):3:subBrandCode 00000408   01-22 13:21:45.689:D / subBrandCodeColoring(14653):4:productname $ 04MS.1.CDC 250g * 48 * 32k   01-22 13:21:45.689:D / subBrandCodeColoring(14653):4:subBrandCode 00000408   01-22 13:21:45.699:D / subBrandCodeColoring(14653):5:productname $ 05MS.1.CSS 120g * 80 * 11k   01-22 13:21:45.709:D / subBrandCodeColoring(14653):5:subBrandCode 00000836   01-22 13:21:45.719:D / subBrandCodeColoring(14653):6:productname $ 06MS.1.CSS 200g * 72 * 16k   01-22 13:21:45.719:D / subBrandCodeColoring(14653):6:subBrandCode 00000836   01-22 13:21:45.749:D / subBrandCodeColoring(14653):7:productname $ 07MS.1.MF BHa 150 * 72 * 20k   01-22 13:21:45.749:D / subBrandCodeColoring(14653):7:subBrandCode 00009206   01-22 13:21:45.759:D / subBrandCodeColoring(14653):8:productname $ 07MS.1.MF BHa 150 + EC * 48   01-22 13:21:45.759:D / subBrandCodeColoring(14653):8:subBrandCode 00009206   01-22 13:21:45.779:D / subBrandCodeColoring(14653):9:productname 1.Duoc Thao 150g * 72 * 24k   01-22 13:21:45.779:D / subBrandCodeColoring(14653):9:subBrandCode 00009377   01-22 13:21:45.879:D / subBrandCodeColoring(14653):0:productname $ 01MS.1.VCF 100g * 144 * 10K   01-22 13:21:45.879:D / subBrandCodeColoring(14653):0:subBrandCode null   01-22 13:21:45.899:D / subBrandCodeColoring(14653):1:productname $ 02MS.1.VCF 160g * 72   01-22 13:21:45.899:D / subBrandCodeColoring(14653):1:subBrandCode null   01-22 13:21:45.919:D / subBrandCodeColoring(14653):2:productname $ 02MS.1.VCF 160g * 72 * 16K   01-22 13:21:45.919:D / subBrandCodeColoring(14653):2:subBrandCode null   01-22 13:21:45.949:D / subBrandCodeColoring(14653):3:productname $ 03MS.1.CDC 200gSPI * 72   01-22 13:21:45.959:D / subBrandCodeColoring(14653):3:subBrandCode null   01-22 13:21:45.979:D / subBrandCodeColoring(14653):4:productname $ 04MS.1.CDC 250g * 48 * 32k   01-22 13:21:45.979:D / subBrandCodeColoring(14653):4:subBrandCode null   01-22 13:21:46.0​​09:D / subBrandCodeColoring(14653):5:productname $ 05MS.1.CSS 120g * 80 * 11k   01-22 13:21:46.0​​09:D / subBrandCodeColoring(14653):5:subBrandCode null   01-22 13:21:46.0​​39:D / subBrandCodeColoring(14653):6:productname $ 06MS.1.CSS 200g * 72 * 16k   01-22 13:21:46.0​​39:D / subBrandCodeColoring(14653):6:subBrandCode null   01-22 13:21:46.0​​59:D / subBrandCodeColoring(14653):7:productname $ 07MS.1.MF BHa 150 * 72 * 20k   01-22 13:21:46.0​​59:D / subBrandCodeColoring(14653):7:subBrandCode null   01-22 13:21:46.0​​79:D / subBrandCodeColoring(14653):8:productname $ 07MS.1.MF BHa 150 + EC * 48   01-22 13:21:46.0​​79:D / subBrandCodeColoring(14653):8:subBrandCode null   01-22 13:21:46.0​​99:D / subBrandCodeColoring(14653):9:productname 1.Duoc Thao 150g * 72 * 24k   01-22 13:21:46.0​​99:D / subBrandCodeColoring(14653):9:subBrandCode null

现在我的问题是,首先在0位置我获得了产品名称和子品牌代码,但在此之后,当它再次搜索0位置时,它会返回null。当null中有value时,为什么我会收到map

Code snippet

    cFilter = db.getOrderDetails(mstrCustCode,strBrandName);
                String lstrProdCode = "";

                try{

                    mylist.clear();

                    if (cFilter != null){ 
                        if (cFilter.moveToFirst()){
                            do {    
                                map = new HashMap<String, String>();
                                map.put("name",cFilter.getString(11).trim());
                                map.put("productcode", cFilter.getString(1).trim());
                                map.put("flag",cFilter.getString(12).trim());
                                map.put("sku",cFilter.getString(13).trim());
                                map.put("subcategorycode",cFilter.getString(15).trim());
                                map.put("subBrandCode", cFilter.getString(6).trim());
}
}

mylist.add(map);  

//my adapter class



public class MyAdapter extends SimpleAdapter 
    {
        public MyAdapter(Context context, ArrayList<HashMap<String,String>> alist, int arow, String[] from,int[] to ){     
            super(context, alist,arow, from,to); 
        }  

        @Override
        public View getView(int position, View convertView, ViewGroup parent) 
        {
            @SuppressWarnings("unchecked")
            HashMap<String, String> hm =(HashMap<String, String>)super.getItem(position);
            View view = (View) super.getView(position, convertView, parent);

            Log.d("subBrandCodeColoring", position+" :productname "+hm.get("productname"));
            Log.d("subBrandCodeColoring", position+" :subBrandCode "+hm.get("subBrandCode"));

0 个答案:

没有答案