欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Androidinclude使用

安卓中,布局include主要是重用布局作用,當(dāng)一個(gè)界面配置較多情況下,采用include可以大大增強(qiáng)  其可讀性。

“專業(yè)、務(wù)實(shí)、高效、創(chuàng)新、把客戶的事當(dāng)成自己的事”是我們每一個(gè)人一直以來堅(jiān)持追求的企業(yè)文化。 成都創(chuàng)新互聯(lián)公司是您可以信賴的網(wǎng)站建設(shè)服務(wù)商、專業(yè)的互聯(lián)網(wǎng)服務(wù)提供商! 專注于網(wǎng)站建設(shè)、成都網(wǎng)站建設(shè)、軟件開發(fā)、設(shè)計(jì)服務(wù)業(yè)務(wù)。我們始終堅(jiān)持以客戶需求為導(dǎo)向,結(jié)合用戶體驗(yàn)與視覺傳達(dá),提供有針對(duì)性的項(xiàng)目解決方案,提供專業(yè)性的建議,創(chuàng)新互聯(lián)建站將不斷地超越自我,追逐市場(chǎng),引領(lǐng)市場(chǎng)!

eg:主布局include一個(gè)layout01布局,layout01布局中include一個(gè)layout02布局。

//layout01.xml

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

    <Button
        android:id="@+id/btnLayout01"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="This btn lies on layout01" />

    <include layout="@layout/layout02" />

</LinearLayout>

//layout02.xml

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

    <Button
        android:id="@+id/btnLayout02"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="This btn lies on layout02" />


</LinearLayout>

//activity_main.xml

<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"
    tools:context="${relativePackage}.${activityClass}" >
    <TextView
        android:id="@+id/tvShow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="This txextview lies on main layout" />
    <include
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/tvShow"
        layout="@layout/layout01" />
</RelativeLayout>

//MainActivity.java

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		Button btnLayout01 = (Button)findViewById(R.id.btnLayout01);
		Button btnLayout02 = (Button)findViewById(R.id.btnLayout02);

		btnLayout01.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Log.d("layout01","btn01 click");
			}
		});
		btnLayout02.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Log.d("layout02","btn02 click");
			}
		});
	}
}

注:采用include方法,可直接認(rèn)為包含(內(nèi)嵌)的界面就是直接寫在當(dāng)前布局文件中的。所以,對(duì)于包含(include)進(jìn)來的界面中的控件,可直接用findViewById()方法找到當(dāng)中的子控件。

from:http://blog.csdn.net/xyz_lmn/article/details/14524567

 1)<include />標(biāo)簽可以使用單獨(dú)的layout屬性,這個(gè)也是必須使用的。

 2)可以使用其他屬性。<include />標(biāo)簽若指定了ID屬性,而你的layout也定義了ID,則你的layout的ID會(huì)被覆蓋,解決方案。

 3)在include標(biāo)簽中所有的android:layout_*都是有效的,前提是必須要寫layout_width和layout_height兩個(gè)屬性。

 4)布局中可以包含兩個(gè)相同的include標(biāo)簽,引用時(shí)可以使用如下方法解決(參考):

本文名稱:Androidinclude使用
分享網(wǎng)址:http://chinadenli.net/article20/giogco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、商城網(wǎng)站、品牌網(wǎng)站制作、網(wǎng)站改版網(wǎng)站內(nèi)鏈、網(wǎng)站排名

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)