Reputation: 64
I have extended the spinner class in order to customize it, but i can't figure out how to use it in my code.
public class mySpinner extends Spinner {
......
}
I have an existing activity that uses a spinner and I want to change it to use mySpinner class.
Originally:
Spinner spinner = (Spinner) textEntryView
.findViewById(R.id.account_spinner);
and
<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" />
first I tried:
mySpinner spinner = (Spinner) textEntryView
.findViewById(R.id.account_spinner);
compile error (makes sense). then I tried:
mySpinner spinner = (mySpinner) textEntryView
.findViewById(R.id.account_spinner);
runtime cast error. Then I changed the layout with the previous line:
<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): Caused by: java.lang.ClassNotFoundException: android.view.mySpinner in loader dalvik.system.PathClassLoader[/data/app/org.sample.sample-1.apk]
This does not seem thst hard but I am missing something. Can someone help? Thank you.
Upvotes: 0
Views: 1310
Reputation: 7979
When using custom View
components in XML, you need to use the complete class path.
<com.example.appname.mySpinner />
Upvotes: 1