0

How I can inflating another layout in bindView? I can with condition change layout.

For example: if(condition) show blank layout

My Code:

 @Override
    public void bindView(View view, Context context, Cursor cursor) {

        final ViewHolder holder = (ViewHolder)view.getTag();
        final int goftarId = cursor.getInt(holder.column_id);


        if(deleteListId.contains(goftarId)) {
            // not worked !!!!
            view = LayoutInflater.from(context).inflate(R.layout.blank_row, null, false); 
        } else {
            // not worked !!!!
            view = LayoutInflater.from(context).inflate(R.layout.default_row, null, false);
        }

        holder.tvText.setText(cursor.getString(holder.column_gtext));
    }

It is very important for me to be optimized.

If you know a better solution, please say me.

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Online98
  • 89
  • 10

1 Answers1

1

I think what you want exactly is to use RecyclerView to show different items. If so, check my codes RecyclerView with different items. You will know how to achieve this after reading.

PS: if you are using ListView, then maybe you need to check getItemViewType() and getItemTypeCount().

Community
  • 1
  • 1
SilentKnight
  • 13,761
  • 19
  • 49
  • 78