2015-05-11 75 views
0

我正在從服務獲取圖像路徑,並且正在從服務中下載並在圖像視圖中顯示。我的問題是如果我向下滾動或向上圖像正在重新加載並更改那裏的位置。如果向上或向下滾動,我的圖像會重新下載並更改位置

public View getView(final int position, View convertView, ViewGroup parent) { 

      Log.d("getview:", "position=" + position); 
      View vi = convertView; 
      final ViewHolder holder; 

      if (convertView == null) { 

       vi = inflater.inflate(R.layout.my_asset_list_item, null); 
       // vi = inflater.inflate(R.layout.my_asset_list_item, parent, 
       // false); 

       holder = new ViewHolder(); 
       holder.tvGroupTitle = (TextView) vi.findViewById(R.id.tvGroupTitle); 
       holder.tvGroupDescription = (TextView) vi 
         .findViewById(R.id.tvGroupDescription); 
       holder.imgscrollchild = (LinearLayout) vi 
         .findViewById(R.id.imgscrollchild); 

       vi.setTag(holder); 
      } else { 
       holder = (ViewHolder) vi.getTag(); 
      } 
      if (data.size() <= 0) { 

       vi.setVisibility(View.GONE); 

      } else { 

       tempValues = null; 
       tempValues = (GroupsModel) data.get(position); 
       for (int k = 0; k < data.size(); k++) { 

       } 
       holder.tvGroupTitle.setText(tempValues.getName().toString()); 
       holder.tvGroupDescription.setText(tempValues.getDescription().toString()); 
       holder.imgscrollchild.removeAllViews(); 


       if (tempValues.getItemmodel().size() == 0) { 
        return vi; 
       } else { 

        for (int i = 0; i < tempValues.getItemmodel().size(); i++) { 
         a = i; 
         Log.i("Index", String.valueOf(i)); 

         holder.imgscrollchild.addView(createimg(tempValues.getItemmodel(), a)); 
         Log.i("Index A", String.valueOf(a)); 

        } 

       } 

      } 
      return vi; 
     } 

回答

1

您可以使用滾動查看而不是listview。例如

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:focusable="true" 
    android:focusableInTouchMode="true" > 

    <LinearLayout 
     android:id="@+id/layoutLoadData" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 
    </LinearLayout> 
</ScrollView> 
  • 在Java文件

    LinearLayout layoutLoadData=(LinearLayout)findViewById(R.id.layoutLoadData); 
    
    
    for (int i = 0; i < adapter.getCount(); i++) { 
    
        View view = adapter.getView(i, null, null); 
        layoutLoadData.addView(view); 
    } 
    
相關問題