循环依赖,需要一些帮助确切code [英] Circular dependencies, need some help with exact code

查看:126
本文介绍了循环依赖,需要一些帮助确切code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是比较新的Andr​​oid和我有以下问题被卡住。我有一个XML布局code,这似乎是工作在1.5,但没有对1.6并进一步与循环依赖不允许和RelativeLayout的。
我GOOGLE上的错误一些信息,和我的基础知识。太少这个话题还是信息。
我还是想不通,这里正是圆形的依赖性发生在我的code。
请,可能有些你点我到线,在出现这种情况,并解释为什么会这样呢?

I'm relatively new to Android and I've stucked with the following problem. I have an xml layout code, which seems to be working on 1.5, but fails on 1.6 and further with Circular dependencies are not allowed with RelativeLayout. I've googled some info on that error, and I got the basics. Still too few info about this topic. I still can't figure, where exactly that circular dependences occur in my code. Please, could some of you point me to the lines, where that happens, and explain why it so?


<LinearLayout  
    android:orientation="horizontal"
    android:layout_width="0dip"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal">
    <ImageView
        android:paddingTop="3dip"
        android:id="@+id/typeicon"
        android:scaleType="center"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>  
</LinearLayout>

<RelativeLayout 
    android:orientation="vertical"
    android:layout_width="0dip"
    android:layout_weight="6.5"
    android:layout_height="fill_parent"
    android:paddingRight="20dip">
    <RelativeLayout
        android:layout_alignParentTop="true"
        android:id="@+id/toprellistlayout"
        android:layout_width="fill_parent"
        android:layout_weight="1"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/trannumbertext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:textStyle="bold"
            android:layout_alignParentLeft="true"/>
        <TextView
            android:id="@+id/summtext"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:layout_alignParentRight="true"
            android:textStyle="bold"/>
    </RelativeLayout>
    <TextView
        android:layout_below="@id/toprellistlayout"
        android:id="@+id/maintranstext"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_gravity="center"
        android:textSize="13sp"
        android:textStyle="bold"
    />
    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_weight="1"
        android:paddingTop="4dip"
        android:layout_below="@id/maintranstext"
        android:id="@+id/toprellistlayout"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/datetext"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight=".3"
            android:textSize="11sp"
            android:text="01.01.0000 00:00:00"
            android:textStyle="bold"
            android:gravity="center"
            android:layout_alignParentLeft="true"/>
        <TextView
            android:id="@+id/statusview"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:layout_weight=".7"
            android:gravity="center"
            android:text="@string/finlist_rejected"
            android:drawableLeft="@drawable/cross"
            android:drawablePadding="5dip"
            android:background="@android:id/empty"
            android:layout_alignParentRight="true"
            android:textStyle="bold"
            android:textSize="11sp"/>
    </RelativeLayout>
</RelativeLayout>

推荐答案

通过部分删除行一小时后,我终于想通,其中认为循环依赖们。



它的出现,即当SDK解析 RelativeLayout的 XML,和定位件 - 它不能采取,例如,在图C,它是在视图B的下方,这是视图A.下面如果你仔细看 - 你会发现在我的code那部分

解决的办法 - 就是使一个额外的 RelativeLayout的,在其中放置的意见C和B

After an hour by partially deleting the lines, I've finally figured, where that "Circular dependencies" were.

It appears, that when SDK parses RelativeLayout xml, and positioning the items - it can't take, for example, the view C, which is below the view B, which is below the view A. If you look carefully - you'll find that part in my code.
The solution - is to make an additional RelativeLayout, in which to place the views C and B.

这篇关于循环依赖,需要一些帮助确切code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆