Android Grid View with Custom base Adapter

后端 未结 3 932
滥情空心
滥情空心 2021-01-21 15:37

i have started to learn android development. i am making an app in which i want to show movie thumbnails(image view and text view) combined in grid view layout i have made custo

3条回答
  •  逝去的感伤
    2021-01-21 15:42

    Here's the solution to your issue. You're using the adapter incorrectly. You're inflating the 'GridView' with the adapter in this line.

    convertView =inflater.inflate(R.layout.activity_main,viewGroup,false);
    

    That's no what you want to do. You want to make an other XML Layout that represents each movie's title in a TextView and image in an Imageview

    
    
    
    
    
    

    This tutorial should help you. It's for a list view but all adapters in android pretty much work the same way. Adapter Tutorial

    I noticed a something you can improve upon. Put your inflator inside you convertview == null. There's no point to creating this object when it's not used.

提交回复
热议问题