I follow the Android Gallery guide ( http://developer.android.com/guide/tutorials/views/hello-gallery.html ), but instead of simple images, I would like to be able to move horizontally to a new new screen, such as LinearLayout. An idea is a kind of tabulation behavior, but the user can scroll through the screens.
I created a gallery, created a GalleryAdapter, which extends from the BaseAdapter and the getItem () method. I am trying to return a complex view:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ScrollView view = (ScrollView)this.c.getResources().getLayout(R.layout.main);
return view;
}
In the above example, it will work if I use ImageView, but it fails if I use a more complex view like scrollView loaded from resources.
Any idea why? The exception is:
07-15 13:47:36.498: ERROR/AndroidRuntime(446): java.lang.ClassCastException: android.content.res.XmlBlock$Parser
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at de.flavor.myviews.GalleryAdapter.getView(GalleryAdapter.java:44)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:192)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.view.View.measure(View.java:8171)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.view.View.measure(View.java:8171)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.view.View.measure(View.java:8171)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
07-15 13:47:36.498: ERROR/AndroidRuntime(446): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
Thanx Sven