2012-02-20 15 views
0

データベースからデータを読み込むカスタムリストビューを作成しました。このデータは、配列に持ち込まれます。カスタムリストビューのスクロールの問題

すべてのデータをリストビューで表示する必要があります。だから問題はない。 私が抱えている問題はスクロールです。私がリストビューをscollすると、遅く実行されるように見えます。

以下

は、私のコードの抜粋です:この上

static class ViewHolder { 
    public TextView txtTitle; 
    public TextView txtDescription; 
    public TextView txtLocations; 
    public TextView txtShowingDate; 
    public TextView txtAdded; 
    public TextView txtProvider; 
    public TextView txtTicketUrl; 
    public ImageView imgProviderImage; 
    } 

public class FilmItemAdapter extends ArrayAdapter<FilmRecord> { 
    public ArrayList<FilmRecord> films; 

    public FilmItemAdapter(Context context, int textViewResourceId, ArrayList<FilmRecord> films) { 
     super(context, textViewResourceId, films); 
     this.films = films; 
    } 

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

     ViewHolder viewHolder = new ViewHolder(); 
     if (convertView == null) { 
      /* There is no view at this position, we create a new one. 
       In this case by inflating an xml layout */ 
      LayoutInflater inflater = LayoutInflater.from(getContext()); 
      convertView = inflater.inflate(R.layout.listitem, null); 

      // Creates a ViewHolder and store references to the two children views 
      // we want to bind data to. 
      //Find find by ID once, and store details in holder. 
      viewHolder.txtTitle = (TextView)convertView.findViewById(R.id.filmtitle); 
      viewHolder.txtShowingDate = (TextView) convertView.findViewById(R.id.filmshowingtime); 
      viewHolder.txtAdded = (TextView) convertView.findViewById(R.id.filmadded); 
      viewHolder.txtLocations = (TextView) convertView.findViewById(R.id.filmlocations); 
      viewHolder.txtDescription = (TextView) convertView.findViewById(R.id.filmdescription); 
      viewHolder.txtProvider = (TextView) convertView.findViewById(R.id.filmprovider); 
      viewHolder.txtTicketUrl = (TextView) convertView.findViewById(R.id.filmticketurl); 
      viewHolder.imgProviderImage = (ImageView) convertView.findViewById(R.id.providerImage); 

      convertView.setTag(viewHolder); 
     } else { 
      /* We recycle a View that already exists */ 
      viewHolder = (ViewHolder) convertView.getTag(); 
     } 

     FilmRecord film = films.get(position); 

     //Get film details from ARRAY and not the database - getting records from a db is time consuming. 
     viewHolder.txtTitle.setText(films.get(position).filmTitle); 
     viewHolder.txtDescription.setText(films.get(position).filmDescription); 
     viewHolder.txtLocations.setText(films.get(position).filmLocations); 
     viewHolder.txtShowingDate.setText("Showing time: " + films.get(position).filmShowingDate); 
     viewHolder.txtAdded.setText("Added on: " + films.get(position).filmAdded); 
     viewHolder.txtProvider.setText(films.get(position).filmProvider); 
     viewHolder.txtTicketUrl.setText(films.get(position).filmTicketUrl); 

     return convertView; 

    } 

} 

ヘルプは、おそらくこれはあなたを助ける素晴らしい:)

答えて

関連する問題