2017-07-27 68 views
2

我的應用程序有Robolectric框架測試的Android Alertdialog。Robolectric與AppCompat庫不兼容AlertDialog的問題

ShadowAlertDialog.getLatestAlertDialog() 

然而,現在AlertDialog改爲android.support.v7.app.AlertDialog正因爲如此Robolectric給我一個不兼容的類型錯誤。

Error:(81, 50) error: incompatible types 
required: android.support.v7.app.AlertDialog 
found: android.app.AlertDialog 

我該如何解決這個問題?

+1

[有](https://github.com/robolectric/robolectric/issues/2232)的問題打開。 – azizbekian

回答

0

這是我們的解決方法(在科特林):

val alertDialog = ShadowDialog.getLatestDialog() as AlertDialog 
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick()