jeudi 29 septembre 2016

Static ViewHolder Pattern. So whats the pattern for onClick inside this static Viewholder?

I know.

 public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener

static ViewHolder its recommended.

also onClick() in ViewHolder constructor its recommended instead of in onBind() method.

public ViewHolder(View v){
        super(v);
        v.setOnClickListener(this);
    }

but know we have inner onClick() in static ViewHolder class

  public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{

        public ViewHolder(View v){
            super(v);
            v.setOnClickListener(this);
        }

        @Override
        public void onClick(View v) {
            Log.d(TAG, "position = " + getAdapterPosition());
        }

and now is my question after all this recommendations.

Whats now its recommended if for example I want to delete item from list in this recycler and notifi adapter.

My list must be static OK.. But still can't use notifyDataSetChanged() in inner onClick();

any recommendations for this? pattern? or usefull example would be great. Or how You doing this in Your projects.

thx!

Aucun commentaire:

Enregistrer un commentaire