只是尋求一些幫助。如果這太模糊,請讓我知道。Android示例,「佈局技巧:合併佈局」不起作用
我想要的「合併佈局」的例子在這裏找到: http://developer.android.com/resources/articles/layout-tricks-merge.html
,我似乎無法得到它的工作。頁面上的源代碼下載不包括所有需要的文件。我在下面粘貼一些代碼,並將其註釋掉。如果這些評論未被評論,我會收到很多錯誤。如果任何人有一個建議之前,我開始粘貼錯誤,那將是巨大的......
OkCancelBar:
package com.example.android.merge;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.widget.Button;
import android.widget.LinearLayout;
public class OkCancelBar extends LinearLayout {
public OkCancelBar(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER);
setWeightSum(1.0f);
LayoutInflater.from(context).inflate(R.layout.okcancelbar, this, true);
/*
TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.OkCancelBar, 0, 0);
String text = array.getString(R.styleable.OkCancelBar_okLabel);
if (text == null) text = "Ok";
((Button) findViewById(R.id.okcancelbar_ok)).setText(text);
text = array.getString(R.styleable.OkCancelBar_cancelLabel);
if (text == null) text = "Cancel";
((Button) findViewById(R.id.okcancelbar_cancel)).setText(text);
array.recycle();
*/
}
}
的main.xml:
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:okCancelBar="http://schemas.android.com/apk/res/com.example.android.merge">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/golden_gate" />
<com.example.android.merge.OkCancelBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="8dip"
android:gravity="center_horizontal"
android:background="#AA000000"
<!--
okCancelBar:okLabel="Save"
okCancelBar:cancelLabel="Don't save"
-->
/>
</merge>
你能發佈的錯誤?當試圖確定問題時,它會有很大的幫助。 – f20k
你想分享壓縮文件到其他地方供我下載?該頁面顯示「找不到錯誤404文件」。謝謝 –