
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:background="#FFFFFF"> <TextVIEw androID:ID="@+ID/photo_cell_contents" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_margintop="10px" androID:text="@string/photo_cell_default_text" androID:textcolor="#000000" androID:textSize="80px"/></linearLayout>
适配器的getVIEw()方法确实被调用,并确实将此视图的实例返回到适配器视图.我还在我的适配器视图中添加了断点,并且可以看到那里存在正确的视图层次结构 – 带有子textvIEw对象的根线性布局.但是,当适配器视图布局并绘制适配器返回的子视图时,不会绘制内部文本视图.我看到对应于每个单元格的实际彩色框,但不是应该出现在内部的文本.有谁知道为什么会发生这种情况?下面是适配器视图的onLayout()方法中的代码,它放置子视图(当我在setAdapter()时添加它们,并在我滚动适配器视图时得到更新):
for (int IDx = 0; IDx < this.getChildCount(); IDx++) { if (IDx != dragged) { Point xy = getCoorFromIndex(IDx); VIEw child = getChildAt(IDx); child.layout(xy.x,xy.y,xy.x + childSize,xy.y + childSize); //vIEw group will layout the children based on the sizes determined for available columns int left = child.getleft(); int right = child.getRight(); int top = child.gettop(); VIEw tv = ((VIEwGroup)child).getChildAt(0); int tvleft = tv.getleft(); int tvright = tv.getRight(); int tvtop = tv.gettop(); Log.i("dgv","Here is info about main vIEw ... left = " + left + "; right = " + right + "; top = " + top); Log.i("dgv","Here is info about text vIEw ... left = " + tvleft + "; right = " + tvright + "; top = " + tvtop); } }解决方法 问题是我需要在适配器视图的布局方法中测量和布局子视图.添加代码以测量子视图然后调用child.layout()后,视图显示正确.希望这可以帮助. 总结 以上是内存溢出为你收集整理的android – 使用adapterview时无法在视图组中绘制子视图全部内容,希望文章能够帮你解决android – 使用adapterview时无法在视图组中绘制子视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)