スピナークラスをカスタマイズするために拡張しましたが、コードでの使用方法がわかりません。
public class mySpinner extends Spinner {
......
}
スピナーを使用する既存のアクティビティがあり、mySpinnerクラスを使用するように変更したいと思います。
元は:
Spinner spinner = (Spinner) textEntryView
.findViewById(R.id.account_spinner);
と
<Spinner
android:id="@+id/account_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/ADALabel1"
android:layout_alignLeft="@+id/newassetsymbol"
android:layout_below="@+id/assetclass_spinner" />
最初に試しました:
mySpinner spinner = (Spinner) textEntryView
.findViewById(R.id.account_spinner);
コンパイルエラー(意味があります)。それから私は試しました:
mySpinner spinner = (mySpinner) textEntryView
.findViewById(R.id.account_spinner);
ランタイムキャストエラー。次に、前の行でレイアウトを変更しました。
<mySpinner
android:id="@+id/account_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/ADALabel1"
android:layout_alignLeft="@+id/newassetsymbol"
android:layout_below="@+id/assetclass_spinner" />
01-12 06:50:02.664:E / AndroidRuntime(597):原因:java.lang.ClassNotFoundException:ローダーdalvik.system.PathClassLoaderのandroid.view.mySpinner [/data/app/org.sample.sample-1 .apk]
これは難しいことではないようですが、私は何かが欠けています。誰かが助けることができますか?ありがとうございました。