开发者

Custom ArrayAdapter getView provides wrong position

So I'm getting an error because my Custom ArrayAdapter getView method provides a position that is outside of the number of items in my list. For instance, when I have one item it returns a position of 1 after I return to this activity.

EDIT:

private class CustomAdapter extends ArrayAdapter<LinearLayout>{
    public CustomAdapter(Context context, int resources, List<LinearLayout> objects){
        super(context, resources, objects);
    }

    public View getView(int position, View convertView, ViewGroup parent){
        LinearLayout row;

        LayoutInflater mInflater = getLayoutInflater();
        if (convertView == null){
            row = getItem(position);
        }
        else{
            row = (LinearLayout) mInflater.inflate(R.layout.list_row, null);

            Te开发者_开发技巧xtView name = (TextView) row.findViewById(R.id.text1);
            name.setText(settingList.get(position).name);

            TextView value = (TextView) row.findViewById(R.id.text2);
            value.setText(settingList.get(position).value);
        }

        return row;
    }
}


The position should be based off of whatever you return in your overridden getCount() method. What are you doing for that?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜