Android,如何从其他方法显式调用onCreate()? [英] Android, How to call onCreate() explicitly from other method?

查看:213
本文介绍了Android,如何从其他方法显式调用onCreate()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打电话给onCreate(Bundle cicici);从其他方法中获取"NullPointerException",因此请指导我如何从另一个方法中调用onCreate().

I want to call onCreate(Bundle cicici); from other method then i am getting "NullPointerException", so please guide me how can i call the onCreate() from another method().

    public void moreFriendsButtonClick(int id)
{
    contentId= id;
    onCreate(tempBundle);
}

我在这里传递int值,并且

Here i am passing int value, and

tempBundle=savedInstanceState;

然后我得到了NullPointerException

and after that i am getting NullPointerException

推荐答案

,您应该再次创建捆绑软件. savedInstanceState在onCreate方法中是本地的. 尝试

you should create the bundle again. savedInstanceState is local to onCreate method. try

Bundle tempBundle = new Bundle();
onCreate(tempBundle);

应该可以.

这篇关于Android,如何从其他方法显式调用onCreate()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆