我要做的就是拥有一个可以从子选项卡访问的 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
}
我已经尝试了很多替代的东西,并且已经到了寻求帮助的地步(对我来说非常罕见)。很明显,我对 android 开发还比较陌生。
编辑:通过类扩展应用程序尝试全局变量时{