[英]How to declare linearlayout in FrameLayout
現在,我繼續我的擴展FrameLayout
。
我如何在該類中聲明LinearLayout
。
例如: LinearLayout followButton =(LinearLayout) findViewById(R.id.transperent);
在普通活動課中,我如何在下課中做到這一點
Public class MyActivity extends FrameLayout {
}
> main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/transperent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
如果有人對此有任何想法,請幫助我的朋友。
在自定義FrameLayout的構造函數中,您可以使用
inflate(context, R.layout.main, this)
這樣, LinearLayout
會自動添加到FrameLayout
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.