日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

android include 使用

系統 2149 0


android include 使用
?

??

?

在main.xml中包含aaa.xml,bbb.xml

aaa.xml
          <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="a" />


</LinearLayout>
        
?
bbb.xml

            <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="a" />


</LinearLayout>

          
?

main.xml

                <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >


    <include
        android:id="@+id/a"
        layout="@layout/aaa" />


    <include
        android:id="@+id/b"
        layout="@layout/bbb" />


</LinearLayout>

              
?

效果圖


android include 使用
?

獲取組件
                    public class LayoutTestActivity extends Activity {
      private LinearLayout l1, l2;
      private TextView tv1, tv2;


      @Override
      public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);


            l1 = (LinearLayout) findViewById(R.id.a);
            tv1 = (TextView) l1.findViewById(R.id.tv);
            l2 = (LinearLayout) findViewById(R.id.b);
            tv2 = (TextView) l2.findViewById(R.id.tv);


            tv1.setText("aaaaaaaaaaaaaaaaaaaaaaaa");
            tv2.setText("bbbbbbbbbbbbbbbbbbbbbbbb");


      }
}

                  
?

效果圖

android include 使用


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。。?/p>

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 湘西| 成安县| 东明县| 东丽区| 兴宁市| 敦煌市| 元氏县| 江永县| 枞阳县| 崇阳县| 乐清市| 太康县| 隆德县| 二手房| 阳泉市| 双流县| 塔城市| 河间市| 青河县| 宁都县| 深水埗区| 余干县| 泉州市| 库尔勒市| 承德市| 深泽县| 沿河| 襄樊市| 新民市| 铜山县| 安陆市| 大同县| 丹巴县| 和林格尔县| 韩城市| 固原市| 沛县| 黑山县| 诸城市| 淳安县| 罗定市|