我需要更新父活动中的片段,但我不断获取 FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.abc_slide_in_bottom, R.anim.abc_slide_out_top, R.anim.abc_slide_in_top, R.anim.abc_slide_out_bottom);
loginFragment = new LoginFragment();
Bundle b = new Bundle();
b.putSerializable(IntentConstants.OPERATORS, supportedCarriers);
b.putString(IntentConstants.OPERATOR_NAME, carrierName);
b.putBoolean(IntentConstants.OPERATOR_SUPPORTED, carrierIsSupported);
loginFragment.setArguments(b);
ft.replace(R.id.welcome_fragment_container, loginFragment);
ft.commit();
并且片段已经在屏幕上。
有谁知道我该怎么做?
以下是我展示片段的方式:
runOnUiThread(new Runnable() {
@Override
public void run() {
loginFragment.setLoginFailed();
}
});
之后我通过执行以下操作从父活动调用片段方法:
java.lang.NullPointerException
at com.app.activities.WelcomeActivity$6$1.run(WelcomeActivity.java:285)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
但是当这样做时,应用程序崩溃了,我在logCat中得到了这个:
{{1}}
答案 0 :(得分:0)