如何正确显示URLS照片数组?

Android应用程序不显示字符串网址。

公共类Mainactivity扩展了AppCompatactivity {

String data = "";



@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    String strJson=null;
    char ch='"';
    try {
        InputStream inputStream = getassets().open("a.json");
        int size = inputStream.available();
        byte [] buffer = new byte[size];
        inputStream.read(buffer);
        inputStream.close();
        strJson = new String(buffer,"UTF-8");
        // Create the root JSONObject from the JSON string.
        JSONObject jsonRootObject = new JSONObject(strJson);

        //Get the instance of JSONArray that contains JSONObjects
        JSONArray jsonArray = jsonRootObject.optJSONArray("urls");

        //Iterate the jsonArray and print the info of JSONObjects
        for(int i=0; i < jsonArray.length(); i++){
            data += ch + jsonArray.getString(i)+ ch + ",\n";


        }

        Toast.makeText(this,data,Toast.LENGTH_LONG).show();

// Toast显示所有内容清晰

    } catch (JSONException | IOException e) {e.printStackTrace();}

}

private String[] urls  = new String[] {data};

}

我认为问题可能出在“数据”字符串传递上。如果我将链接放在私有String []中,网址= new String [] {“ URLLING”}; -它可以工作,但是如果我放一个字符串数组不显示任何内容,将不胜感激:)

dafeizi520 回答:如何正确显示URLS照片数组?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3141819.html

大家都在问