我基本上想要访问我的布局,以便当用户点击当前屏幕上的任意位置时我可以移动到下一个屏幕。 这是我的xml代码。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/hellolayout">
<TextView
android:text="WELCOME!"
android:textSize="50dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:id="@+id/textView1"
android:layout_centerHorizontal="true" />
<ImageView
android:src="@drawable/idiotic_smile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:id="@+id/imageView1" />
</LinearLayout>
在课堂上,&#39; hellolayout&#39;不被承认。我有什么遗漏要包括在内吗?
LinearLayout l = FindViewById<LinearLayout> (Resource.Id.hellolayout);
答案 0 :(得分:0)
访问布局应该像R.layout.YourLayoutName
一样简单。要加载它,请使用setContentView(R.layout.YourLayoutName)
。
更好地参考文档here。