Rusfearuth
Rusfearuth

Reputation: 3261

How to add view inside of Gallery widget in android

G'day!

I wanna do the next:

<Gallery ...>
    <TextView ... />
    <TextView ... /> <!-- and etc -->
</Gallery>

I've done a custom TextViewAdapter which contains List inside and set that adapter to gallery.

In that case, I have that error: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView

Upvotes: 0

Views: 551

Answers (1)

Samir Mangroliya
Samir Mangroliya

Reputation: 40416

You can not add any view in gallery in xml file.

Using Adapter you can add view in gallery.so in

public class GalleryAdapter extends BaseAdapter

and in getView(...) method inflate row.And row have all your view which you want to add in gallery.and using Inflator inflate row.

And setadapter to gallery... gallery.setAdapter(new GalleryAdapter())

Upvotes: 1

Related Questions