orhanobut / dialogplus

Advanced dialog solution for android
Apache License 2.0
5k stars 793 forks source link

setContentHolder(new ViewHolder(view)) NullPointerException #169

Open QXH313 opened 6 years ago

QXH313 commented 6 years ago

1.Use in Android is not in kotlin

2. View view = View.inflate(context, R.layout.content, null); return DialogPlus.newDialog(context) .setContentHolder(new ViewHolder(view)) .setGravity(Gravity.TOP) .setContentWidth(ViewGroup.LayoutParams.MATCH_PARENT) .setContentHeight(ViewGroup.LayoutParams.WRAP_CONTENT) .setContentBackgroundResource(R.color.transparent) .setOverlayBackgroundResource(R.color.transparent) .setCancelable(true) .setExpanded(false) .create();

3. java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setBackgroundResource(int)' on a null object reference at com.orhanobut.dialogplus.ViewHolder.getView(ViewHolder.java:56) at com.orhanobut.dialogplus.DialogPlus.createView(DialogPlus.java:252) at com.orhanobut.dialogplus.DialogPlus.initContentView(DialogPlus.java:223) at com.orhanobut.dialogplus.DialogPlus.(DialogPlus.java:111) at com.orhanobut.dialogplus.DialogPlusBuilder.create(DialogPlusBuilder.java:260)

dhruvbajpai commented 5 years ago

I have the same issue. Can someone help with this.

seop-archisketch commented 5 years ago

I had the same issue, and in my case the problem was that, the library uses a file called dialog_view.xml so it conflicted with my dialog, which was named the same. I renamed my file and it worked fine.

desanlesr95 commented 4 years ago

...was the file dialog_view.xml, thanks