11月 082012
package name “jp.hotaka.test”
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- name : custom view class name -->
<declare-styleable name="HogeStyle">
<attr format="string" name="hogeType" />
</declare-styleable>
</resources>
Preference の xml
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:Hoge="http://schemas.android.com/apk/res/jp.hotaka.test" >
<jp.hotaka.test.HogePreference
hogeStyle:hogeType="hogehoge"
android:layout="@layout/hoge"
android:summary="summary"
android:title="title"
/>
HogePreference.java
package jp.hotaka.test;
class HogePreference extends Preference {
public HogePreference(Context context) {
super(context);
mContext = context;
}
public HogePreference (Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray tArray = context.obtainStyledAttributes(attrs,
R.styleable.HogeStyle);
String hoge = tArray.getString(R.styleable.HogeStyle_hogeType);
}
@Override
protected void onBindView(View view) {
super.onBindView(view);
// mTextView= (TextView)view.findViewById(R.id.hoge);
}
}
だいぶ hoge hoge しました。
以上、自分の作ったXMLで定義した画面を使って、好きなように画面を変える