そうそう、Viewのカスタマイズをこの前試した
そのメモ
とりあえず準備
[xml]
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="SampleView">
<attr name="array" format="integer" />
</declare-styleable>
</resources>
[/xml]
declare-styleableについてはyanzmさんの declare-styleable メモ を読むといい。
上記の意味としてはSampleViewでは独自プロパティarrayというintを受け取るよーという宣言みたいな感じ(たぶん)
以下のような形で呼び出す
[xml]
<jp.kamip.SampleProject.SampleView
android:key="sample_key"
android:title="sample"
custom:array="@array/sample_array"
/>
[/xml]
呼び出す際は以下のプロパティが親Viewに必要。親Viewは上記のViewを内包しているView。
[xml]
xmlns:custom="http://schemas.android.com/apk/res/jp.kamip.SampleProject"
[/xml]
[java]
TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.SampleView);
mArray = a.getResourceId(0, 0);
[/java]
こんな感じで取得するんだった。
これ出来ると独自View作りたくなっちゃうのでおすすめ。僕はPreferenceを継承した独自Viewを作ってました。