如何转换的ArrayList<串GT;字符串[] [英] How to Convert arraylist<string> to string[]

查看:105
本文介绍了如何转换的ArrayList<串GT;字符串[]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public SampleGridViewAdapter(Context context,ArrayList<String> urls) {
    this.context = context;
    this .urls=urls;
    Log.i("DDDDDDDDDD",String.valueOf(urls));
    simpleArray = urls.toArray(new String[urls.size()]);
    Log.i("GGGGGGGGGGG",String.valueOf(simpleArray));
}

当我打印 DDDDDDD 在日志中,输出的URL的ArrayList,但是当我看到 GGGGGGG ,它改变 05-09 [Ljava.lang.String; @ b125cf00

When I print DDDDDDD in the log, the output is an arraylist of URL's, but when I see GGGGGGG, it changes to 05-09 [Ljava.lang.String;@b125cf00

推荐答案

您可以转换的ArrayList为String []做到这一点。

You can do this for converting ArrayList to String[].

public SampleGridViewAdapter(Context context,ArrayList<String> urls) {
    this.context = context;
    this .urls=urls;
    Log.i("DDDDDDDDDD",String.valueOf(urls));
    String[] simpleArray = new String[urls.size()];
    simpleArray = urls.toArray(simpleArray);
    Log.i("GGGGGGGGGGG",String.valueOf(simpleArray));
}

或者你也可以做到这一点的方式 -

OR you can also do this way -

public SampleGridViewAdapter(Context context,ArrayList<String> urls) {
    this.context = context;
    this .urls=urls;
     Log.i("DDDDDDDDDD",String.valueOf(urls));
     Object[] simpleArray = urls.toArray();

     for(int i = 0; i < simpleArray.length ; i++){
     Log.d("string is",(String)simpleArray[i]);
    }
  Log.i("GGGGGGGGGGG",String.valueOf(simpleArray));
}   

这篇关于如何转换的ArrayList&LT;串GT;字符串[]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆