开发者

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));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜