13
我有幾個關於使用Robolectric測試DialogFragment
類的問題,因爲我在Internet上完全沒有關於此主題的信息。使用Robolectric測試DialogFragments
- 什麼是正確的參數傳遞給
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
? 我有麻煩參數傳遞給
DialogFragment
,我使用以下方法:activity = new Activity(); dialog = new DialogFragment(); Bundle bundle = new Bundle(); dialog.setArguments(bundle); FragmentManager fm = activity.getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.add(dialog, "fragment"); ft.commit();
每當代碼試圖訪問其與NullPointerException
崩潰的論點。
請高度評價這些主題的任何想法。
您可以包含DialogFragment類的代碼嗎?有沒有理由不使用DialogFragment#show()?該文檔顯示瞭如何擴展DialogFragment以創建自己的自定義對話框:http://developer.android.com/reference/android/app/DialogFragment.html – user697495
您是否解決了這個問題? –
@Egor,你解決了這個問題嗎? –