1

I am using robotium 3.6 and I want to get the current visible fragment of android.support.v4.app.FragmentActivity. How to do this?

4

1 回答 1

1

假设您实际上正在使用 FragmentActivity,那么 solo.getCurrentActivity() 应该返回您想要的活动,但它将被强制转换为活动,您需要将其强制转换为普通 java 中的 android.support.v4.app.FragmentActivity方法:

android.support.v4.app.FragmentActivity fragmentActivity = (android.support.v4.app.FragmentActivity) solo.getCurrentActivity();

如果你在 tabhost 或类似的地方有这个,这可能不起作用。

于 2012-12-05T23:13:13.443 回答