Java parse提供空值
我已经成功地从另一个数据库获取数据,并可以在TextView上打印它。但是当我尝试将数据传递到下面这样的Java parse提供空值,java,android,null,Java,Android,Null,我已经成功地从另一个数据库获取数据,并可以在TextView上打印它。但是当我尝试将数据传递到下面这样的Uri.pase()中时,它会给我null public void gotosite(View v) { s = responseTextView.getText().toString(); Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://"+s+"")); startActivity(i); }
Uri.pase()
中时,它会给我null
public void gotosite(View v) {
s = responseTextView.getText().toString();
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://"+s+""));
startActivity(i);
}
此方法提供预期数据的TextView打印。我想在Uri.parse()处设置数据
public void setTextToTextView(JSONArray-JSONArray){
字符串s=“”;
for(int i=0;i
您需要全局声明字符串,以便在不同的方法中使用。确保先运行setTextToTextView
方法,然后以String s=”“
的形式运行gotosite()
方法
字符串s;//在全球范围内宣布这一点
公共void setTextToTextView(JSONArray JSONArray){
for(int i=0;iLog.d(“空检查”,s)代码>是一个很好的开始问题解决了,谢谢@stealthjonghow可以从所有数据中获取特定记录。。。我不想在sql中使用where条件。我只想从JSON数组中获取一条特定的记录。
public void setTextToTextView(JSONArray jsonArray) {
String s = "";
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject json = null;
try {
json = jsonArray.getJSONObject(i);
s = s + json.getString("adUrl");
} catch (JSONException e) {
e.printStackTrace();
}
}
this.responseTextView.setText(s);
}
String s; // declare this globally
public void setTextToTextView(JSONArray jsonArray) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject json = null;
try {
json = jsonArray.getJSONObject(i);
s = s + json.getString("adUrl");
} catch (JSONException e) {
e.printStackTrace();
}
}
this.responseTextView.setText(s);
}
public void gotosite(View v) {
s=responseTextView.getText().toString(); // either use this or you can now use string s directly
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://"+s+""));
startActivity(i);
}