我怎么能在一个完全不同的方法使用一个本地方法变量? [英] How can I use a local method variable in a totally different method?
本文介绍了我怎么能在一个完全不同的方法使用一个本地方法变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了这样的方法...
I have a method written like this...
public void getRequest(String Url) {
runOnUiThread(new Runnable() {
public void run() {
// TODO Auto-generated method stub
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
try {
HttpResponse response = client.execute(request);
Toast.makeText(MenuUtama.this, request(response) ,Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
}
我需要能够访问本地变量要求
的另一种方法,这样我可以叫 request.response
。我怎么能够从一个完全不同的方法来访问这个本地方法?
I need to be able to access the local variable request
in another method, so that I can call request.response
. How am I able to access this local method from a totally different method?
推荐答案
增加的响应,并要求变量的作用域,我的意思是不是在方法层面在声明类级别这些变量。
Increase the scope of variables of response and and request,I mean declare these variable at class level not in method level.
这篇关于我怎么能在一个完全不同的方法使用一个本地方法变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文