when loading a fragment.
After scrolling, data is smoothly displayed. but again disappera
Viewing the Android list in the scroll content becomes invisible only for version 2.3. works great for 4.0 and up. the problem is when I browse the ListView, the data disappears and the images will only be shown. If I scroll smoothly and tap for one or two seconds. the data will be displayed in the list, but when scrolling, the data disappears.
Below is my adapter code -
public class RestaurantListAdapter extends BaseAdapter {
private ArrayList<RestaurantList> restaurantList;
private LayoutInflater inflater;
private ImageLoader imageLoader;
private Context context;
private ViewHolder viewHolder = null;
DisplayImageOptions options;
public RestaurantListAdapter(Activity activity,
ArrayList<RestaurantList> restaurantList) {
this.context = activity;
this.restaurantList = restaurantList;
this.inflater = LayoutInflater.from(this.context);
imageLoader = ImageLoader.getInstance();
options = new DisplayImageOptions.Builder().cacheInMemory(true)
.cacheOnDisc(true).bitmapConfig(Bitmap.Config.RGB_565).build();
}
public int getCount() {
return restaurantList.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
viewHolder = new ViewHolder();
convertView = inflater.inflate(
R.layout.restaurant_list_item_layout, null);
viewHolder.restaurantNameTextView = (TextView) convertView
.findViewById(R.id.restaurantNameTextView);
viewHolder.restaurantAddressTextView = (TextView) convertView
.findViewById(R.id.restaurantAddressTextView);
viewHolder.restaurantPinTextView = (TextView) convertView
.findViewById(R.id.restaurantPinTextView);
viewHolder.restaurantPhoneTextView = (TextView) convertView
.findViewById(R.id.restaurantPhoneTextView);
viewHolder.favoriteImageButton = (ImageButton) convertView
.findViewById(R.id.favoriteImageButton);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
RestaurantList restaurant = restaurantList.get(position);
viewHolder.restaurantNameTextView.setText(restaurant
.getRestaurantName());
viewHolder.restaurantAddressTextView.setText(restaurant
.getRestaurantAddress());
viewHolder.restaurantPinTextView.setText(restaurant.getRestaurantPin());
viewHolder.restaurantPhoneTextView.setText(restaurant
.getRestaurantPhone());
viewHolder.favoriteImageButton.setFocusable(false);
viewHolder.restaurantNameTextView.setVisibility(View.VISIBLE);
return convertView;
}
static class ViewHolder {
TextView restaurantNameTextView;
TextView restaurantAddressTextView;
TextView restaurantPinTextView;
TextView restaurantPhoneTextView;
ImageButton favoriteImageButton;
ImageView restaurentImageView;
}
}
source
share