我正在尝试使用<include>标记在android应用程序中重用一些布局组件.我有不同的港口和土地布局:
港口:
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<include layout="@layout/calc_equals_button" a:layout_weight="4"/>
<include layout="@layout/calc_display"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)土地:
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<include layout="@layout/calc_equals_button"/>
<include layout="@layout/calc_display"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)主要的区别是a:layout_weight="4",所以我希望我的calc_equals_button组件在端口方向上更小.
问题是,如果我尝试calc_equals_button直接嵌入组件一切正常,例如:
<LinearLayout a:layout_weight="1" a:layout_width="match_parent" a:layout_height="0dp">
<DirectionDragButton
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/equalsButton"
a:text="="
a:layout_width="match_parent"
a:layout_height="match_parent"
a:layout_weight="4"
style="@style/control_button_style"
a:onClick="numericButtonClickHandler"/>
<include layout="@layout/calc_display"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
否则 - 不是.
以下是calc_equals_button.xml的示例:
<DirectionDragButton
xmlns:a="http://schemas.android.com/apk/res/android"
a:id="@+id/equalsButton"
a:text="="
a:layout_width="match_parent"
a:layout_height="match_parent"
style="@style/control_button_style"
a:onClick="numericButtonClickHandler"/>
Run Code Online (Sandbox Code Playgroud) 我想知道在JAXB中是否支持不同版本的类.我对它的看法:xml是类的一种持久化对象(序列化值),但是由于开发(例如扩展功能),可以改变类对象.有没有办法知道只使用JAXB API在持久性(read:xml)中存储哪个版本的类?
对我来说,存储类版本似乎很方便 - 就像它在标准的java序列化机制(我的意思是serialVersionUID)中所做的那样,并提供在类上映射xml的功能,即使在不同版本的情况下(例如,在XmlAdapter中添加关于存储在xml中的类的版本的信息) ).默认情况下,如果xml和运行时中的类版本不同 - 抛出InvalidClassException.
示例:我们的课程测试如下:
@XmlRootElement
@XmlAccessorType(value = XmlAccessType.FIELD)
public class Test {
private Long time;
private Test () {};
}
Run Code Online (Sandbox Code Playgroud)
假设时间是以毫秒为单位的UNIX时间.
此代码在生产时发布,此类作为xml保存在数据库中.下一个版本显示使用Long作为时间表示并且它已更改为Date不是一个好选择:
@XmlRootElement
@XmlAccessorType(value = XmlAccessType.FIELD)
public class Test {
private Date time;
private Test () {};
}
Run Code Online (Sandbox Code Playgroud)
现在有两种方法 - 迁移持久化数据或编写将处理长时间并将其应用于日期时间的xml适配器.
如果我们选择第二种方式,那么如果JAXB API提供存储在xml中的类版本(假设在class = 0版本中没有指定类版本)并且我们显式添加新版本的类(通过注释或静态)领域):
@XmlRootElement
@XmlAccessorType(value = XmlAccessType.FIELD)
@XmlClassVersion(value = 1)
public class Test {
private Date time;
private Test () {};
}
Run Code Online (Sandbox Code Playgroud)
要么
@XmlRootElement
@XmlAccessorType(value = XmlAccessType.FIELD)
public class Test {
private static …Run Code Online (Sandbox Code Playgroud) 为什么在销毁Activity之前我应该为AlertDialog调用dismiss()方法?有什么东西泄漏,但到底是什么?为什么PopupWindow可以处理Activity破坏?
我在Android源代码中发现每个警报对话框都会创建窗口:
Window w = PolicyManager.makeNewWindow(mContext);
Run Code Online (Sandbox Code Playgroud)
那是什么意思?为什么它不能只使用从活动中获得的PhoneWindow?
添加
再说了,AlertDialog引用的上下文,上下文引用不存在,则应该GC垃圾收集两个对象(因为它们不是从"外部"引用).还有什么提到AlertDialog?换句话说,内存泄漏到底在哪里?