Android 重用Layout

<include> tag basically means ‘take that file and paste it’s contents here’

<merge > The layout which we have to use must be enclosed under merge tag, so that we can include layouts from other xmls.

[u][/u]
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/Button11"
android:text="Button11"></Button>
<Button android:layout_below="@id/Button01"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/Button12" android:text="Button12"></Button>
</LinearLayout>
</merge>


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:id="@+id/RelativeLayout02"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true">
<Button android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Next Activity "></Button>
</RelativeLayout>
<RelativeLayout android:id="@+id/RelativeLayout03"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<include layout="@layout/footer" />
</RelativeLayout>
</RelativeLayout>


public class Splash extends Activity implements OnClickListener {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

findViewById(R.id.Button01).setOnClickListener(this);
findViewById(R.id.Button11).setOnClickListener(this);
findViewById(R.id.Button12).setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.Button01:
startActivity(new Intent(this, Act2.class));
break;
case R.id.Button11:
Toast.makeText(this, "Button 11 - Activity 1 ....",
Toast.LENGTH_SHORT).show();
break;
case R.id.Button12:
Toast.makeText(this, "Button 12 - Activity 1 ....",
Toast.LENGTH_SHORT).show();
break;
}
}

}


You can download its complete source code from here .[url]http://www.megaupload.com/?d=XZ3KTOGI[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值