Add RelativeLayout or ListView inside Gallery View in Android?
Can开发者_运维问答 someone let me know how to add RelativeLayout
or listview
inside GalleryView
. I have tried by returning listview
or RelativeLayout
from the adapter of Gallery but it gives ClassCastException java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams.
Can someone let me know how to go about it?
When you set the LayoutParams of a view, you need to use the specific LayoutParams of the parent view. In your case, you have to use Gallery.LayoutParams as shown here:
ListView listView = new ListView(cont);
listView.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
精彩评论