首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将字符串数组与自定义适配器一起使用到listview?

将字符串数组与自定义适配器一起使用到listview?
EN

Stack Overflow用户
提问于 2016-07-16 00:41:08
回答 0查看 2.4K关注 0票数 1

所以我有一个字符串数组。我尝试将字符串数组中的每个单独项传递给自定义适配器。我很难弄清楚如何使用我在自定义适配器中传递的字符串?

我传递的String[]

代码语言:javascript
运行
复制
 String favorites = String.valueOf(FavList.get(0).get("favorites_list"));

                String[] separated = favorites.split(",");

                for (String s: separated) {
                    //Do your stuff here
                    FavoritesAdapter.add(s);
                }

Adapter.class

代码语言:javascript
运行
复制
public class FavoritesAdapter extends ArrayAdapter<favoriteList> {
private final Context mContext;
private List<favoriteList> favlist;
private TextView favorites;
private TextView favDetail;

public FavoritesAdapter(Context context, ArrayList<favoriteList> objects) {
    super(context, R.layout.favorites_listview_single, objects);
    this.mContext = context;
    this.favlist = objects;
}


public View getView(final int position, View convertView, final ViewGroup parent) {
    if (convertView == null) {
        LayoutInflater mLayoutInflater = LayoutInflater.from(mContext);
        convertView = mLayoutInflater.inflate(R.layout.favorites_listview_single, null);
    }


   // Here is where i cant figure out how to get the string that I passed.






    return convertView;
}

}

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38401201

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档