Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.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
Java parse提供空值_Java_Android_Null - Fatal编程技术网

Java parse提供空值

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); }

我已经成功地从另一个数据库获取数据,并可以在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);
}
此方法提供预期数据的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;i
Log.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);

    }