第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

listview getView()方法,圖片超范圍加載

listview getView()方法,圖片超范圍加載

蒲公英wsg 2017-09-29 20:33:50
這是 ?在getview()方法中 加載圖片 的模塊,但是我用圖片選擇器選擇一張圖片,轉(zhuǎn)換成字符流,存到集合里,上傳到服務(wù)器。在適配器中讀取集合中的字符流,顯示在imageview中。為什么我上傳了一張,缺顯示了很多,打了斷點(diǎn),就是上傳一張,但是 為什么顯示了多張 ?》嗚嗚嗚嗚~~~~~~~~~這是 getview()方法中,加載圖片的模塊,到底該怎么解決那?int?a=data.getPhoto().size(); ImageView[]?imageViews?=?new?ImageView[a]; for?(int?j?=?0;?j?<a;?j++)?{ ????final?ImageView?imageView?=?new?ImageView(mContext); ????imageView.setLayoutParams(new?LinearLayout.LayoutParams(UtilTools.getWidth(mContext)/2,?UtilTools.getHeight(mContext)/2)); ????UtilTools.getImage(mContext,imageView,data.getPhoto().get(j)); ????imageViews[j]?=?imageView; ????viewHolder1.ll_ll.addView(imageViews[j]); }這是整個(gè)適配器的代碼public?class?SellAdapter?extends?BaseAdapter?implements?View.OnClickListener?{ ????private?Context?mContext; ????private?List<Sell>?mList; ????//布局加載器 ????private?LayoutInflater?inflater; ????private?Sell?data; ????????private?Callback?mCallback; ???????????/** ????????????*?自定義接口,用于回調(diào)按鈕點(diǎn)擊事件到Activity ????????????*?@author?Ivan?Xu ????????????*?2014-11-26 ????????????*/ ???????????public?interface?Callback?{ ???????????????public?void?click(View?v); ???????????} ????public?SellAdapter(Context?mContext,?List<Sell>?mList,?Callback?callback)?{ ????????this.mContext?=?mContext; ????????this.mList?=?mList; ????????mCallback?=?callback; ????????//獲取系統(tǒng)服務(wù) ????????inflater?=?(LayoutInflater)?mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ????} ????@Override ????public?int?getCount()?{ ????????return?mList.size(); ????} ????@Override ????public?Object?getItem(int?i)?{ ????????return?mList.get(i); ????} ????@Override ????public?long?getItemId(int?i)?{ ????????return?i; ????} ????@Override ????public?View?getView(int?i,?View?view,?ViewGroup?viewGroup)?{ ????????ViewHolder?viewHolder1=null; ????????//如果是第一次加載 ????????if(view==null){ ????????????viewHolder1=new?ViewHolder(); ????????????view=inflater.inflate(R.layout.item_sell,null); ????????????viewHolder1.iv_logo=(ImageView)?view.findViewById(R.id.sell_item_logo); ????????????viewHolder1.tv_name=(TextView)view.findViewById(R.id.sell_item_name); ????????????viewHolder1.tv_title=(TextView)view.findViewById(R.id.sell_item_title); ????????????viewHolder1.tv_content=(TextView)view.findViewById(R.id.sell_item_content); ????????????viewHolder1.iv_message=(ImageView)?view.findViewById(R.id.sell_item_message); ????????????viewHolder1.ll_ll=(LinearLayout)?view.findViewById(R.id.sell_item_ll); ????????????//設(shè)置緩存 ????????????view.setTag(viewHolder1); ????????} ????????else?{ ????????????viewHolder1?=?(ViewHolder)view.getTag(); ????????} ????????//設(shè)置數(shù)據(jù) ????????data=mList.get(i); ????????viewHolder1.tv_name.setText(data.getName()); ????????viewHolder1.tv_title.setText(data.getTitle()); ????????viewHolder1.tv_content.setText(data.getContent()); ????????viewHolder1.iv_message.setOnClickListener(this); ????????viewHolder1.iv_message.setTag(i); ????????if?(data.getImage()!=null){ ????????????UtilTools.getImage(mContext,viewHolder1.iv_logo,mList.get(i).getImage()); ????????} //????????list!=null?&&?!list.isEmpty() ????????????int?a=data.getPhoto().size(); ????????????ImageView[]?imageViews?=?new?ImageView[a]; ????????????for?(int?j?=?0;?j?<a;?j++)?{ ????????????????final?ImageView?imageView?=?new?ImageView(mContext); ????????????????imageView.setLayoutParams(new?LinearLayout.LayoutParams(UtilTools.getWidth(mContext)/2,?UtilTools.getHeight(mContext)/2)); ????????????????UtilTools.getImage(mContext,imageView,data.getPhoto().get(j)); ????????????????imageViews[j]?=?imageView; ????????????????viewHolder1.ll_ll.addView(imageViews[j]); ????????????} ????????//將邏輯改成必須添加圖片,就不用考慮這部分了 //????????else?{ //????????????//還是加個(gè)什么吧,要不然的話,老崩潰,我也不知道為什么 //????????????//稍微加點(diǎn)東西,讓人感覺不到,不可見就OK了 // //????????????TextView?t=new?TextView(mContext); //????????????t.setLayoutParams(new?LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,2)); //????????????t.setVisibility(View.INVISIBLE); //????????????viewHolder1.ll_ll.addView(t); // // // // //????????} ????????return?view; ????} ????//響應(yīng)按鈕點(diǎn)擊事件,調(diào)用子定義接口,并傳入View ????@Override ????public?void?onClick(View?view)?{ ????????mCallback.click(view); ????} ????class?ViewHolder{ ????????private?LinearLayout?ll_ll; ????????private?ImageView?iv_logo; ????????private?TextView?tv_name; ????????private?TextView?tv_title; ????????private?TextView?tv_content; ????????private??ImageView?iv_message; ????} }該怎么解決那?大家?guī)蛶兔h~~~~~~~~~
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1717 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)