У меня есть класс фрагмента диалога ниже с интерфейсом, который выдает следующее исключение:
** java.lang.ClassCastException: **
public class FolderPickerDialog extends DialogFragment {
@Override
public void onAttach(Context context) {
this.listner=(FolderPickerDialog.FolderPickerListner)context;
super.onAttach(context);
}
public interface FolderPickerListner {
void onFolderSelected(String path)
}
}
Я реализовал слушателя в следующем классе:
public class SaveDialog extends DialogFragment implements FolderPickerDialog.FolderPickerListner {
@Override
public void onFolderSelected(String path) {
ic_path.setText(path);
}
}
Мой журнал Cat
java.lang.ClassCastException: com.nanosoft.icstudio.activities.MainActivity cannot be cast to com.nanosoft.icstudio.Dialogs.FolderPickerDialog$FolderPickerListner
at com.nanosoft.icstudio.Dialogs.FolderPickerDialog.onAttach(FolderPickerDialog.java:43)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1231)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:710)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5765)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)