Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 访问tabhost';s JSONObject或JSONArray_Android_Json_Tabs_Arraylist_Android Tabhost - Fatal编程技术网

Android 访问tabhost';s JSONObject或JSONArray

Android 访问tabhost';s JSONObject或JSONArray,android,json,tabs,arraylist,android-tabhost,Android,Json,Tabs,Arraylist,Android Tabhost,我所要做的就是拥有一个可以从子选项卡访问的JSONObject,这样我就可以将信息放入其中 public class Example extends TabActivity{ private JSONObject testtt = new JSONObject(); public void writeJSON(String key, String value) throws JSONException { testtt.put(key,

我所要做的就是拥有一个可以从子选项卡访问的JSONObject,这样我就可以将信息放入其中

 public class Example extends TabActivity{
            private JSONObject testtt = new JSONObject();
        public void writeJSON(String key, String value) throws JSONException {
         testtt.put(key, value);
         }
        public String getJSON(){
            return testtt.toString();
        }
     public void onCreate(Bundle savedInstanceState) {
                    super.onCreate(savedInstanceState);
            setContentView(R.layout.example);
                    //Creating the tabs and everything
                    //Is Here
     }
    }
我有“下一步/上一步”按钮,可以来回导航选项卡 其中一个选项卡:

public void onClick(View v) {
 //Pre-alertDialog.setmessage stuff here.
   alertDialog.setMessage(Example.this.getJSON());
// Example.this gives this error: No enclosing instance of the type Example is accessible in scope
}
我已经尝试了大量的替代品,并且已经到了寻求帮助的地步(对我来说非常罕见)。 很明显,我对安卓系统的开发还比较陌生

编辑: 尝试通过类扩展应用程序执行全局变量时{

最简单的方法是使用对象:将JSON粘贴到应用程序对象中的共享变量上,然后在其他活动中从那里访问它。

我尝试了……强制关闭(我也将其作为应用程序添加到清单中)崩溃错误是什么?从logcat添加整个异常跟踪。这可能需要一段时间…愚蠢的我删除了所有代码而不是注释。logcat屏幕截图…它在以下代码行中断:Jason Jason=(Jason)getApplicationContext();我解决了自己的问题…我正在向清单中添加一个…而我需要做的只是将名称添加到现有标记中。参考: