Java 如何获取access RelativeLayout作为变量?
我不知道如何以编程方式访问RelativeLayout,以便调用方法,例如Java 如何获取access RelativeLayout作为变量?,java,android,android-layout,android-relativelayout,Java,Android,Android Layout,Android Relativelayout,我不知道如何以编程方式访问RelativeLayout,以便调用方法,例如RelativeLayout.getChildCount()在处理程序中 编辑-好的,如果我想获得RelativeLayout中的视图总数,我会调用什么函数?在文件夹res/layout中,我假设您的布局名为layout.xml 确保你的亲戚有android:id段 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
RelativeLayout.getChildCount()代码>在处理程序中
编辑-好的,如果我想获得RelativeLayout中的视图总数,我会调用什么函数?在文件夹res/layout中,我假设您的布局名为layout.xml
确保你的亲戚有android:id段
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myRelativeLayout" > //the id name can be acsessed in activity
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
在文件夹res/layout中,我假设您的布局名为layout.xml
确保你的亲戚有android:id段
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/myRelativeLayout" > //the id name can be acsessed in activity
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</RelativeLayout>
请澄清您的问题是的,但这里的问题是我想获得在XML相对布局中定义的视图数量,如何将其链接到java表单?请澄清您的问题是的,但这里的问题是我想获得在XML相对布局中定义的视图数量,如何将其链接到java表单?