Android 引用类
示例
资料模型
public class Item {
private String name;
public String getName() {
return name;
}
}布局XML
您必须像在Java中那样导入引用的类。
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="android.view.View"/>
<variable name="item" type="com.example.Item"/>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- We reference the View class to set the visibility of this TextView -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{item.name}"
android:visibility="@{item.name == null ?View.VISIBLE: View.GONE"/>
</LinearLayout>
</layout>注意:软件包java.lang.*由系统自动导入。(同样的被由JVM供Java)
热门推荐
4 天仙配简短祝福语
10 元旦祝福语 简短独特群发
11 鼠年同事祝福语简短创意
12 新婚贺词祝福语创意简短
13 上级生日祝福语 简短独特
14 早上祝福语简短句子
15 学生国庆简短的祝福语
16 朋友祝福语卡片简短大气
17 发文章祝福语简短英语
18 简短元旦祝福语古言