本文介绍了显示器和QUOT;零" STR1"当传递&QUOT值;其他类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class ServerResponce extends ListActivity {
private ArrayList<listobj> tobj = new ArrayList<listobj>();
**static String str1;**
PickUpLocation pickup=new PickUpLocation();
String pickuplocid= pickup.locationid;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new MyTask().execute();
}
private class MyTask extends AsyncTask<Void, Void, Void>
{
private ProgressDialog progressDialog;
protected void onPreExecute() {
progressDialog = ProgressDialog.show(ServerResponce.this,
"", "Loading. Please wait...", true);
}
@Override
protected Void doInBackground(Void... arg0) {
try {
URL tURL= new URL("http://qrrency.com/mobile/j2me/cab/CabBooking.php?userid=1&from=home&to=office&datetime=&cabservicetype=1&cabtype=1&cabfeatures=AC&locationid="+pickuplocid+"");
BufferedReader inn = new BufferedReader(new InputStreamReader(tURL.openStream()));
int p=0;
StringBuffer buffer1=new StringBuffer();
while ((p=inn.read())!=-1)
{
buffer1.append((char)p);
str1=str1+(char)p;
} Log.i("Line----saurabh trivedi-ddddd----", str1);
inn.close();
我把类的对象,并转移 STR1
值到其他类ServerResponce
I make object of class and transfer the str1
value to other class ServerResponce
servresp=new ServerResponce();
String serv= servresp.str1;
Log.i("tag",serv);
网络
是显示空为什么?
推荐答案
当你的字符串是静态的,那么你不需要创建该类的Objetc。对于第二个活动的参考,你可以使用。
When your String is static then you dont need to create Objetc of that class.For reference in 2nd Activity you could use.
ServerResponse.str1;
在你的第二个活动
这篇关于显示器和QUOT;零&QUOT; STR1&QUOT;当传递&QUOT值;其他类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!