Java 每次输出都会得到null。例如;nullid:1 nullName:sufyan nullFatherName“;

Java 每次输出都会得到null。例如;nullid:1 nullName:sufyan nullFatherName“;,java,android,Java,Android,每次输出都会得到null。下面是一节课: @override public void onResponse(String response) { try { JSONArray jsonArray = new JSONArray(response); for(int i = 0 ; i < jsonArray.length

每次输出都会得到null。下面是一节课:

@override
 public void onResponse(String response) {


                        try {

                            JSONArray jsonArray = new JSONArray(response);
                      
      for(int i = 0 ; i < jsonArray.length() ; i++){

                                JSONObject jsonObject = 
jsonArray.getJSONObject(i);



                                String id  = jsonObject.getString("id");

                                String name  = jsonObject.getString("name");

                                String fathername  = 
jsonObject.getString("fathername");

                                String no  = jsonObject.getString("no");

                                jsonResponseId += "Id: " + id + "\n\n";

                                jsonResponseName += "Name: " + name + "\n\n";

                                jsonResponseFather += "FatherName: " + 
fathername + "\n\n";

                                jsonResponseNumber += "Number: " + no + "\n\n";

                                idText.setText(jsonResponseId);

                                nameText.setText(jsonResponseName);

                                fatherNameText.setText(jsonResponseFather);

                                numberText.setText(jsonResponseNumber);

                            }

}
}
@覆盖
公共void onResponse(字符串响应){
试一试{
JSONArray JSONArray=新JSONArray(响应);
for(int i=0;i
您应该将
+=
替换为
=


因为
+=
经常用于数字。您应该对字符串使用
append
初始化变量jsonResponseId等,使其不为空,

一个更简单的解决方案是去掉这些变量,然后像这样设置它们

idText.setText("Id: " + id + "\n\n");

你能提供json响应吗请提供你的json对象,没有它我们就不能help@SufyanShabbir我想建议你在弦接合处使用