当我想删除项目时,我收到了此错误:
java.lang.NoSuchMethodError:类Lir / adapters / GridRecycleAdapter中没有虚方法notifyItemRemoved(I)V;或其超级类(声明' ir.adapters.GridRecycleAdapter'出现在/data/app/ir.selfinsta-1/split_lib_directories_apk.apk)
代码:
public class GridRecycleAdapter extends RecyclerView.Adapter {
private final String TAG = "GridRecycleAdapter";
private ArrayList<Item> items;
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//some code
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder h, int position) {
//some code
}
@Override
public void onViewRecycled(RecyclerView.ViewHolder h) {
//some code
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public int getItemCount() {
return items.size() ;
}
@Override
public int getItemViewType(int position) {
return position;
}
/*
* for remove item
*/
private void removeItem(int position){
//remove item
items.remove(position);
notifyItemRemoved(position);
notifyItemRangeChanged(position,items.size());
}
}
build.gradle:
compileSdkVersion 26
buildToolsVersion '27.0.3'
build.gradle depency:
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:support-v13:26.1.0'