开发者

GridView with customs view

I don't know if it is possible, but actually I wouldn't see why not.

Can we do a grid view not just with ImageView but with a custom view.

I am trying to make a grid view of a view composed of an ImageView and a TextView.

I know that everything happens in my Adapter getView's function but I can't figure out how to do it.

public View getView(int position, View convertView, ViewGroup parent) {
    View cases = findViewById(R.id.fileUnitLayout);

    if (convertView == null) {
       convertView = new View(mContext);
    } else {
       cases = convertView;
    }

       return cases;
    }

My view has an id of R.id.fileUnitLayout. Let's say my inner TextView has an id of A and my inner ImageView has an id of开发者_StackOverflow社区 B. How can I fill them ?

Thank you,


You should not need to override getView to accomplish this, necessarily. GridView is an AdapterView so you can provide an adapter that will display what you want via setAdapter

You could, for example, use SimpleAdapter to provide an xml file that is used for each grid view item.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜