I made a header for my RecyclerView
which, when clicked, opens a Dialog. Some time later, it started to give this error:
Activity com.mypkg.myP has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44c46ff0 that was originally added here
05-17 18:24:57.069: ERROR/WindowManager(18850): android.view.WindowLeaked: Activity ccom.mypkg.myP has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44c46ff0 that was originally added here
05-17 18:24:57.069: ERROR/WindowManager(18850): at android.view.ViewRoot.<init>(ViewRoot.java:231)
05-17 18:24:57.069: ERROR/WindowManager(18850): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
05-17 18:24:57.069: ERROR/WindowManager(18850): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
I saw in this post that this would be resolved by closing the Dialog in onPause
or onDestroy
.
How do I go from within the adapter?
Code that creates Dialog
in Adapter
:
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof VHHeader) {
final VHHeader VHheader = (VHHeader) holder;
VHheader.enviardica.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Dialog dpartilha = new Dialog(ctx);
dpartilha.requestWindowFeature(Window.FEATURE_NO_TITLE);
dpartilha.setContentView(R.layout.partilha);
LinearLayout laydicas = (LinearLayout) dpartilha.findViewById(R.id.laydicas);
LinearLayout layeventos = (LinearLayout) dpartilha.findViewById(R.id.layeventos);
dpartilha.show();
}
});