Milos Cuculovic
Milos Cuculovic

Reputation: 20223

Android and ListView with a very poor and slow scroll

I have a customized listview. In this list, I have something like 15 items. When I am trying to scroll, the scroll is very slow and not smooth.

Here is my listView:

 <ListView
  android:id="@+id/AnnouncementsList"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_marginTop="25dp"
  android:cacheColorHint="#00000000"
  android:fastScrollEnabled="true"
  android:scrollingCache="true"
  android:smoothScrollbar="true" 
  android:layout_marginLeft="5dp"
  android:layout_marginRight="5dp"/>

And here is my List Adapter:

public class AnnouncementsListAdapter extends BaseAdapter {

private static ArrayList<NewsAnnouncements_Database> announcementsArrayList;

private LayoutInflater mInflater;

public AnnouncementsListAdapter(Context context, ArrayList<NewsAnnouncements_Database> searchResults) {
     announcementsArrayList = searchResults;
     mInflater = LayoutInflater.from(context);
 }


 public int getCount() {
  return announcementsArrayList.size();
 }


 public Object getItem(int position) {
  return announcementsArrayList.get(position);
 }


 public long getItemId(int position) {
  return position;
 }


 public View getView(int position, View convertView, ViewGroup parent) {
  ViewHolder holder;
  if (convertView == null) {     
       convertView = mInflater.inflate(R.layout.announcements_customisation, null);
       holder = new ViewHolder();
       holder.AnnouncementsTitle = (TextView) convertView.findViewById(R.id.AnnouncementsTitle);
       holder.AnnouncementsContent = (TextView) convertView.findViewById(R.id.AnnouncementsContent);
       convertView.setTag(holder);
  }
  else {
   holder = (ViewHolder) convertView.getTag();
  } 
  holder.AnnouncementsTitle.setText(Html.fromHtml(announcementsArrayList.get(position).getTitle()));
  holder.AnnouncementsContent.setText(Html.fromHtml(announcementsArrayList.get(position).getContent()));
  return convertView;
}

 static class ViewHolder {
  TextView AnnouncementsTitle;
  TextView AnnouncementsContent;
 }

}

Upvotes: 0

Views: 971

Answers (1)

deister
deister

Reputation: 125

try removing cacheColorHint attribute int he XML layout.

Upvotes: 1

Related Questions