1

いくつかの条件に基づいて 2 つのビューのいずれかを返す拡張 SimpleCrussorAdopter があります。

 public ListAdapter(Context context, int layout, Cursor c, String[] from,
        int[] to, int flags) {
     super(context, layout, c, from, to, flags);

 }
  @Override
  public int getViewTypeCount() {
     return 2;
}


 @Override
  public int getItemViewType(int position) {

   if(condition == true) return 1;
    else return 0;
  }


  @Override

     public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView ;

     if( getItemViewType(position) == 1){

    if(convertView == null){
        convertView = inflater.inflate(R.layout.row1, parent, false);
          rowView = (View)convertView;
      }else
      {
         rowView = (View)convertView;
        }

  }else
     {
        //inflate and the second view row2, in the above manner
 } return rowView;
}

以下は、ビュー バインダーです。

  adapter.setViewBinder(new PuzzleListAdapter.ViewBinder() {
                public boolean setViewValue(View view, Cursor cursor, int columnIndex)         {
                    int percent =    cursor.getColumnIndex(PuzzleDatabase.KEY_PUZZLE_PERCENT_COMPLETED);

                    if (percent == columnIndex) {

                        ProgressBar pbar = (ProgressBar) view ;
                        int progress = cursor.getInt(columnIndex);
                        pbar.setProgress(progress);
                        return true;
                    }
                    return false;
                }
            });  

このビュー ワインダーは、SimpleCrussorAdapter のオブジェクトと完全に連携します。

何が問題になる可能性がありますか

問題 1: SimpleCrussorAdaptor を拡張すると、その親クラスの機能を使用して croussor col 列をビューにバインドできません。

問題 2: 拡張された SimpleCrussorAdaptor を使用すると、カスタム ビュー バインダーも機能しません。

私は何かが欠けていますか?

4

0 に答える 0