Giter VIP home page Giter VIP logo

Comments (8)

aesean avatar aesean commented on May 22, 2024

try notifyItemInserted(index); notifyItemRemoved(index);

from recyclerview-animators.

aesean avatar aesean commented on May 22, 2024

Don't use notifyDataSetChanged();

from recyclerview-animators.

tellfa avatar tellfa commented on May 22, 2024

@aesean tnx, Where do I add the code? It is possible to guide me further?

from recyclerview-animators.

aesean avatar aesean commented on May 22, 2024

mRecyclerView.setAdapter(mAdapter);
mAdapter class

from recyclerview-animators.

tellfa avatar tellfa commented on May 22, 2024

@aesean , my adapter code :
public class profile_user_adapter extends
RecyclerView.Adapter<profile_user_adapter.ViewHolder> {
private static String[] mDataset;

public profile_user_adapter(String[] myDataset) {
    mDataset = myDataset;
}
@Override
public profile_user_adapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemLayoutView = LayoutInflater.from(parent.getContext()).inflate(
            R.layout.newsms_card_layout, null);
    ViewHolder viewHolder = new ViewHolder(itemLayoutView);return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
    viewHolder.tvVersionName.setText(mDataset[position].toString());
}
@Override
public int getItemCount() {
    return mDataset.length;
}
public static class ViewHolder extends RecyclerView.ViewHolder {
    public TextView tvVersionName;
    public ViewHolder(View itemLayoutView) {
        super(itemLayoutView);
        tvVersionName = (TextView) itemLayoutView.findViewById(R.id.sms_newsms_text);
        itemLayoutView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }
}

}

if possible you add this methods too my adapter? tnx <3

from recyclerview-animators.

aesean avatar aesean commented on May 22, 2024

public class profile_user_adapter extends RecyclerView.Adapter<profile_user_adapter.ViewHolder> {
private List < String > mDataset;
public profile_user_adapter(List < String > myDataset){
this.mDataset =myDataset;
}

public void insertItem(String item){
    insertItem(item, mDataset.size());
}

public void insertItem(String item,int index){
    mDataset.add(item);
    notifyItemInserted(index);
}

public void removeItem(String item,int index){
    mDataset.remove(index);
    notifyItemRemoved(index);
}

@Override
public profile_user_adapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemLayoutView = LayoutInflater.from(parent.getContext()).inflate(
            R.layout.newsms_card_layout, null);
    ViewHolder viewHolder = new ViewHolder(itemLayoutView);
    return viewHolder;
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {

}

@Override
public int getItemCount() {
    return mDataset.size();
}

public static class ViewHolder extends RecyclerView.ViewHolder {
    public TextView tvVersionName;

    public ViewHolder(View itemLayoutView) {
        super(itemLayoutView);
        tvVersionName = (TextView) itemLayoutView.findViewById(R.id.sms_newsms_text);
        itemLayoutView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
    }
}

}

from recyclerview-animators.

tellfa avatar tellfa commented on May 22, 2024

@aesean , tnx man <3

from recyclerview-animators.

wasabeef avatar wasabeef commented on May 22, 2024

Please use the following
notifyItemChanged(int)
notifyItemInserted(int)
notifyItemRemoved(int)
notifyItemRangeChanged(int, int)
notifyItemRangeInserted(int, int)
notifyItemRangeRemoved(int, int)

If you want your animations to work, do not rely on calling notifyDataSetChanged();
as it is the RecyclerView's default behavior, animations are not triggered to start inside this method.

from recyclerview-animators.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.