当我单击其他recyclerview中的某个视图时,我想在自定义对话框中显示recyclerview, 这另一个recyclerview工作正常,所以我只是 因此,我只是带来了onclick方法,并为此工作使用了Material Dialog。
但是当我尝试给我空对象引用时,我尝试了很多事情,但是我无法使其正常工作,
logcat:
07-25 21:42:38.128 31627-31627/ir.kaho.kaho E/AndroidRuntime: FATAL EXCEPTION: main
Process: ir.kaho.kaho, PID: 31627
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference
at ir.kaho.kaho.Adapters.PruductAdapter2$3$1.onsucces(PruductAdapter2.java:217)
at ir.kaho.kaho.API.ApiService$35.onResponse(ApiService.java:612)
at ir.kaho.kaho.API.ApiService$35.onResponse(ApiService.java:607)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:72)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
我确定我的适配器可以正常工作,并且API也可以正常工作,所以这是Onclick项
适配器-OnbindViewHolder内:
holder.product_items_view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ApiService apiService = new ApiService(context);
apiService.GetHomeSubcategory2(33, new Interface.OnHomeSubCategoryRecive() {
@Override
public void onsucces(List<Subcategory> subcategoryList) {
MaterialDialog dialog = new MaterialDialog.Builder(context)
.cancelable(true)
.title("title")
.customView(R.layout.item_custom_dialog, true)
.build();
RecyclerView list = dialog.getRecyclerView();
list.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
list.setAdapter(new HomeSubCategoryAdapter(context, subcategoryList, new Interface.OnHomeSubCategory() {
@Override
public void OnClick(Subcategory subcategorylist) {
}
}));
dialog.show();
}
@Override
public void onOnFailure() {
}
});
}
});
和item_custom_dialog是xml,我需要在对话框中显示 我无法在根标签和recyclerview中将其constrantLayout粘贴(idk为什么),id = custom_dialog_rv 那么你们怎么想?我在哪里犯错? 请问我该如何解决?
thx伙计们