如何TextView
从 Activity A中更新DialogFragment
?
就我而言,单击中的关闭按钮后DialogFragment
,我需要调用可以更改的方法TextView
这是来自的方法Activity
:
public void setCountText(String text){
CountItem = (TextView) findViewById(R.id.tv_numOfItem);
CountItem.setText(text);
}
中的 Onclick 按钮DialogFragment
:
View.OnClickListener closeHandler = new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new menufeedActivity().setQountText(getCount);
InfoOrderDialog.this.dismiss();
};
};
有谁知道如何解决这个问题?
04-29 03:08:17.513: E/AndroidRuntime(1738): FATAL EXCEPTION: main
04-29 03:08:17.513: E/AndroidRuntime(1738): java.lang.NullPointerException
04-29 03:08:17.513: E/AndroidRuntime(1738): at android.app.Activity.findViewById(Activity.java:1744)
04-29 03:08:17.513: E/AndroidRuntime(1738): at com.example.android.rssfeed.menufeedActivity.setQountText(menufeedActivity.java:169)
04-29 03:08:17.513: E/AndroidRuntime(1738): at com.example.android.rssfeed.InfoOrderDialog$2.onClick(InfoOrderDialog.java:110)
04-29 03:08:17.513: E/AndroidRuntime(1738): at android.view.View.performClick(View.java:3110)
04-29 03:08:17.513: E/AndroidRuntime(1738): at android.view.View$PerformClick.run(View.java:11928)
04-29 03:08:17.513: E/AndroidRuntime(1738): at android.os.Handler.handleCallback(Handler.java:587)
04-29 03:08:17.513: E/AndroidRuntime(1738): at android.os.Handler.dispatchMessage(Handler.java:92)
04-29 03:08:17.513: E/AndroidRuntime(1738): at android.os.Looper.loop(Looper.java:132)
04-29 03:08:17.513: E/AndroidRuntime(1738): at android.app.ActivityThread.main(ActivityThread.java:4025)
04-29 03:08:17.513: E/AndroidRuntime(1738): at java.lang.reflect.Method.invokeNative(Native Method)
04-29 03:08:17.513: E/AndroidRuntime(1738): at java.lang.reflect.Method.invoke(Method.java:491)
04-29 03:08:17.513: E/AndroidRuntime(1738): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-29 03:08:17.513: E/AndroidRuntime(1738): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-29 03:08:17.513: E/AndroidRuntime(1738): at dalvik.system.NativeStart.main(Native Method)