嘗試在寫好的ViewPager中添加listView出錯
直接使用FindViewById報空指針,使用Inflater來FindViewById獲取到ListView但是綁定適配器失敗。
public?void?initGoodList(){ data=new?ArrayList<Map<String,Object>>(); // LayoutInflater?inflater?=?getLayoutInflater(); // View?shopList=inflater.inflate(R.layout.shop,?null); listView=(ListView)?findViewById(R.id.shopList); //listView=(ListView)?shopList.findViewById(R.id.shopList); //listView=(ListView)?findViewById(R.id.shopList); //Toast.makeText(this,?""+listView,?Toast.LENGTH_LONG).show(); //Log.i("listview",?"MyListView"+listView); sim_Adapter=new?SimpleAdapter(this,?getData(),?R.layout.goods_item, new?String[]{"goodImg","goodInfo"},new?int[]{R.id.goodImg,R.id.goodInfo}); listView.setAdapter(sim_Adapter); }