我从服务获取图像路径,我从服务下载并在图像视图中显示。我的问题是如果我向下或向上滚动图像正在重新加载并改变位置。
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;
}
答案 0 :(得分:1)
您可以使用Scrollview代替listview。 e.g。
<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);
}