Discussion:
You must supply a resource ID for a TextView
Wouter
2009-09-18 10:02:26 UTC
Permalink
Hey,

I have a weird problem. For days i have a working list with movie
details i get from an xml rpc source. It loads the list very well and
I tried it again today and when i scroll down, always at the same list
item it gives me this error. I don't know what the problem is. It
shows my list items very good and now not anymore. If you want i can
give you my source code too! And it worked a few days ago and now
suddenty not :(

09-18 11:50:00.940: ERROR/ArrayAdapter(1561): You must supply a
resource ID for a TextView
09-18 11:50:00.950: DEBUG/AndroidRuntime(1561): Shutting down VM
09-18 11:50:00.950: WARN/dalvikvm(1561): threadid=3: thread exiting
with uncaught exception (group=0x4001aa28)
09-18 11:50:00.950: ERROR/AndroidRuntime(1561): Uncaught handler:
thread main exiting due to uncaught exception
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):
java.lang.IllegalStateException: ArrayAdapter requires the resource ID
to be a TextView
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:
347)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.moviemeter.SeparatedListAdapter.getView
(SeparatedListAdapter.java:93)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.AbsListView.obtainView(AbsListView.java:1255)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ListView.addViewBelow(ListView.java:2795)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ListView.scrollListItemsBy(ListView.java:2725)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ListView.arrowScrollImpl(ListView.java:2225)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ListView.arrowScroll(ListView.java:2172)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ListView.commonKey(ListView.java:1977)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ListView.onKeyDown(ListView.java:1924)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.KeyEvent.dispatch(KeyEvent.java:893)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.View.dispatchKeyEvent(View.java:3647)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:744)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ListView.dispatchKeyEvent(ListView.java:1909)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.TabHost.dispatchKeyEvent(TabHost.java:272)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:
2329)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2299)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1621)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.os.Looper.loop(Looper.java:123)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.app.ActivityThread.main(ActivityThread.java:4203)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
java.lang.reflect.Method.invoke(Method.java:521)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
dalvik.system.NativeStart.main(Native Method)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): Caused by:
java.lang.ClassCastException: android.widget.LinearLayout
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:
340)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561): ... 40 more

This is my cinemaAdapter class for making my list!

private class cinemaAdapter extends ArrayAdapter<FilmDetail> {

private List<FilmDetail> items;

public cinemaAdapter(Context context, List<FilmDetail> films)
{
super(context, R.layout.cinema_row, films);
this.items = films;
}
public View getView(int position, View convertView, ViewGroup
parent) {
View v = convertView;
FilmDetail o = items.get(position);

if (v == null) {
LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.cinema_row, null);
}

if (o != null) {
TextView tt = (TextView) v.findViewById
(R.id.text1);
TextView genre = (TextView) v.findViewById
(R.id.genre);
TextView directors = (TextView) v.findViewById
(R.id.regisseur);
TextView actors = (TextView) v.findViewById
(R.id.acteurs);
TextView votes = (TextView) v.findViewById
(R.id.votes);
ImageView imgCinema = (ImageView)
v.findViewById(R.id.imgCinema);
RatingBar cinemaRating = (RatingBar)
v.findViewById(R.id.cinemarating);

if (tt != null)
{
tt.setText(o.getTitle() + " (" + o.getYear
() + ")");
}
if (genre !=null)
{
if (o.getDuration().equals("0"))
{
genre.setText(o.getGenres_text());
}
else{
genre.setText(o.getGenres_text() + ", " +
o.getDuration() + " minuten");
}
}
if (directors != null)
{
directors.setText(o.getDirectors_text());
}
if (actors != null)
{
actors.setText(o.getActors_text());
}
if (votes != null)
{
if (o.getVotes_count().equals("0"))
{
votes.setText(" (geen stemmen)");
}
else {
votes.setText(" (" + o.getVotes_count()+ "
stemmen)");
}

}
if (imgCinema != null)
{
int map = 0;
int filmId = Integer.valueOf(o.getFilmId());
if (filmId >= 1000)
map = Integer.valueOf(o.getFilmId().substring
(0, Integer.valueOf(o.getFilmId().length()) - 3) + "000");

String url = "http://www.moviemeter.nl/images/
covers/" + map + "/" + filmId + ".jpg";
Bitmap bitmap = moviemeterUtils.loadBitmap
(url.toString());
imgCinema.setImageBitmap(bitmap);
}

if (cinemaRating != null)
{
cinemaRating.setRating(Float.valueOf
(o.getAverage()));
}
}
return v;
}
}

Thank you for helping me!
Wouter
2009-09-18 12:47:34 UTC
Permalink
Really dont find what the problem is, the weird is it worked and i
havent changed anything :(
Post by Wouter
Hey,
I have a weird problem. For days i have a working list with movie
details i get from an xml rpc source. It loads the list very well and
I tried it again today and when i scroll down, always at the same list
item it gives me this error. I don't know what the problem is. It
shows my list items very good and now not anymore. If you want i can
give you my source code too! And it worked a few days ago and now
suddenty not :(
09-18 11:50:00.940: ERROR/ArrayAdapter(1561): You must supply a
resource ID for a TextView
09-18 11:50:00.950: DEBUG/AndroidRuntime(1561): Shutting down VM
09-18 11:50:00.950: WARN/dalvikvm(1561): threadid=3: thread exiting
with uncaught exception (group=0x4001aa28)
thread main exiting due to uncaught exception
java.lang.IllegalStateException: ArrayAdapter requires the resource ID
to be a TextView
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
347)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.moviemeter.SeparatedListAdapter.getView
(SeparatedListAdapter.java:93)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.AbsListView.obtainView(AbsListView.java:1255)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.addViewBelow(ListView.java:2795)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.scrollListItemsBy(ListView.java:2725)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScrollImpl(ListView.java:2225)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScroll(ListView.java:2172)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.commonKey(ListView.java:1977)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.onKeyDown(ListView.java:1924)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.KeyEvent.dispatch(KeyEvent.java:893)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.View.dispatchKeyEvent(View.java:3647)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:744)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.dispatchKeyEvent(ListView.java:1909)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.TabHost.dispatchKeyEvent(TabHost.java:272)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
2329)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2299)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1621)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Looper.loop(Looper.java:123)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.ActivityThread.main(ActivityThread.java:4203)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invoke(Method.java:521)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: android.widget.LinearLayout
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
340)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     ... 40 more
This is my cinemaAdapter class for making my list!
 private class cinemaAdapter extends ArrayAdapter<FilmDetail> {
        private List<FilmDetail> items;
        public cinemaAdapter(Context context, List<FilmDetail> films)
{
                super(context, R.layout.cinema_row, films);
                this.items = films;
        }
        public View getView(int position, View convertView, ViewGroup
parent) {
                View v = convertView;
                FilmDetail o = items.get(position);
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.cinema_row, null);
                }
                if (o != null) {
                        TextView tt = (TextView) v.findViewById
(R.id.text1);
                        TextView genre = (TextView) v.findViewById
(R.id.genre);
                        TextView directors = (TextView) v.findViewById
(R.id.regisseur);
                        TextView actors = (TextView) v.findViewById
(R.id.acteurs);
                        TextView votes = (TextView) v.findViewById
(R.id.votes);
                        ImageView imgCinema = (ImageView)
v.findViewById(R.id.imgCinema);
                        RatingBar cinemaRating = (RatingBar)
v.findViewById(R.id.cinemarating);
                        if (tt != null)
                        {
                           tt.setText(o.getTitle() + " (" + o.getYear
() + ")");
                        }
                        if (genre !=null)
                        {
                                if (o.getDuration().equals("0"))
                                {
                                        genre.setText(o.getGenres_text());
                                }
                                else{
                                        genre.setText(o.getGenres_text() + ", " +
o.getDuration() + " minuten");
                                }
                        }
                        if (directors != null)
                        {
                           directors.setText(o.getDirectors_text());
                        }
                        if (actors != null)
                        {
                           actors.setText(o.getActors_text());
                        }
                        if (votes != null)
                        {
                                if (o.getVotes_count().equals("0"))
                                {
                                        votes.setText(" (geen stemmen)");
                                }
                                else {
                                        votes.setText(" (" + o.getVotes_count()+ "
stemmen)");
                                }
                        }
                        if (imgCinema != null)
                        {
                                int map = 0;
                                int filmId = Integer.valueOf(o.getFilmId());
                                if (filmId >= 1000)
                                        map = Integer.valueOf(o.getFilmId().substring
(0, Integer.valueOf(o.getFilmId().length()) - 3) + "000");
                                String url = "http://www.moviemeter.nl/images/
covers/" + map + "/" + filmId + ".jpg";
                                Bitmap bitmap = moviemeterUtils.loadBitmap
(url.toString());
                                imgCinema.setImageBitmap(bitmap);
                        }
                        if (cinemaRating != null)
                        {
                                cinemaRating.setRating(Float.valueOf
(o.getAverage()));
                        }
                }
                return v;
        }
    }
Thank you for helping me!
Wouter
2009-09-18 14:16:03 UTC
Permalink
I removed my seperatedlistadapter and now it worked.. :s But it was
working before with my seperatedlistadapter :(
Post by Wouter
Really dont find what the problem is, the weird is it worked and i
havent changed anything :(
Post by Wouter
Hey,
I have a weird problem. For days i have a working list with movie
details i get from an xml rpc source. It loads the list very well and
I tried it again today and when i scroll down, always at the same list
item it gives me this error. I don't know what the problem is. It
shows my list items very good and now not anymore. If you want i can
give you my source code too! And it worked a few days ago and now
suddenty not :(
09-18 11:50:00.940: ERROR/ArrayAdapter(1561): You must supply a
resource ID for a TextView
09-18 11:50:00.950: DEBUG/AndroidRuntime(1561): Shutting down VM
09-18 11:50:00.950: WARN/dalvikvm(1561): threadid=3: thread exiting
with uncaught exception (group=0x4001aa28)
thread main exiting due to uncaught exception
java.lang.IllegalStateException: ArrayAdapter requires the resource ID
to be a TextView
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
347)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.moviemeter.SeparatedListAdapter.getView
(SeparatedListAdapter.java:93)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.AbsListView.obtainView(AbsListView.java:1255)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.addViewBelow(ListView.java:2795)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.scrollListItemsBy(ListView.java:2725)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScrollImpl(ListView.java:2225)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScroll(ListView.java:2172)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.commonKey(ListView.java:1977)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.onKeyDown(ListView.java:1924)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.KeyEvent.dispatch(KeyEvent.java:893)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.View.dispatchKeyEvent(View.java:3647)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:744)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.dispatchKeyEvent(ListView.java:1909)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.TabHost.dispatchKeyEvent(TabHost.java:272)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
2329)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2299)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1621)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Looper.loop(Looper.java:123)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.ActivityThread.main(ActivityThread.java:4203)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invoke(Method.java:521)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: android.widget.LinearLayout
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
340)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     ... 40 more
This is my cinemaAdapter class for making my list!
 private class cinemaAdapter extends ArrayAdapter<FilmDetail> {
        private List<FilmDetail> items;
        public cinemaAdapter(Context context, List<FilmDetail> films)
{
                super(context, R.layout.cinema_row, films);
                this.items = films;
        }
        public View getView(int position, View convertView, ViewGroup
parent) {
                View v = convertView;
                FilmDetail o = items.get(position);
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.cinema_row, null);
                }
                if (o != null) {
                        TextView tt = (TextView) v.findViewById
(R.id.text1);
                        TextView genre = (TextView) v.findViewById
(R.id.genre);
                        TextView directors = (TextView) v.findViewById
(R.id.regisseur);
                        TextView actors = (TextView) v.findViewById
(R.id.acteurs);
                        TextView votes = (TextView) v.findViewById
(R.id.votes);
                        ImageView imgCinema = (ImageView)
v.findViewById(R.id.imgCinema);
                        RatingBar cinemaRating = (RatingBar)
v.findViewById(R.id.cinemarating);
                        if (tt != null)
                        {
                           tt.setText(o.getTitle() + " (" + o.getYear
() + ")");
                        }
                        if (genre !=null)
                        {
                                if (o.getDuration().equals("0"))
                                {
                                        genre.setText(o.getGenres_text());
                                }
                                else{
                                        genre.setText(o.getGenres_text() + ", " +
o.getDuration() + " minuten");
                                }
                        }
                        if (directors != null)
                        {
                           directors.setText(o.getDirectors_text());
                        }
                        if (actors != null)
                        {
                           actors.setText(o.getActors_text());
                        }
                        if (votes != null)
                        {
                                if (o.getVotes_count().equals("0"))
                               
...
meer lezen »
Yusuf Saib (T-Mobile USA)
2009-09-18 16:41:20 UTC
Permalink
Where in your code is SeparatedListAdapter.java:93? And can you post
the resource xml as well?



Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.
Post by Wouter
I removed my seperatedlistadapter and now it worked.. :s But it was
working before with my seperatedlistadapter :(
Post by Wouter
Really dont find what the problem is, the weird is it worked and i
havent changed anything :(
Post by Wouter
Hey,
I have a weird problem. For days i have a working list with movie
details i get from an xml rpc source. It loads the list very well and
I tried it again today and when i scroll down, always at the same list
item it gives me this error. I don't know what the problem is. It
shows my list items very good and now not anymore. If you want i can
give you my source code too! And it worked a few days ago and now
suddenty not :(
09-18 11:50:00.940: ERROR/ArrayAdapter(1561): You must supply a
resource ID for a TextView
09-18 11:50:00.950: DEBUG/AndroidRuntime(1561): Shutting down VM
09-18 11:50:00.950: WARN/dalvikvm(1561): threadid=3: thread exiting
with uncaught exception (group=0x4001aa28)
thread main exiting due to uncaught exception
java.lang.IllegalStateException: ArrayAdapter requires the resource ID
to be a TextView
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
347)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.moviemeter.SeparatedListAdapter.getView
(SeparatedListAdapter.java:93)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.AbsListView.obtainView(AbsListView.java:1255)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.addViewBelow(ListView.java:2795)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.scrollListItemsBy(ListView.java:2725)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScrollImpl(ListView.java:2225)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScroll(ListView.java:2172)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.commonKey(ListView.java:1977)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.onKeyDown(ListView.java:1924)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.KeyEvent.dispatch(KeyEvent.java:893)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.View.dispatchKeyEvent(View.java:3647)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:744)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.dispatchKeyEvent(ListView.java:1909)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.TabHost.dispatchKeyEvent(TabHost.java:272)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
2329)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2299)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1621)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Looper.loop(Looper.java:123)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.ActivityThread.main(ActivityThread.java:4203)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invoke(Method.java:521)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: android.widget.LinearLayout
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
340)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     ... 40 more
This is my cinemaAdapter class for making my list!
 private class cinemaAdapter extends ArrayAdapter<FilmDetail> {
        private List<FilmDetail> items;
        public cinemaAdapter(Context context, List<FilmDetail> films)
{
                super(context, R.layout.cinema_row, films);
                this.items = films;
        }
        public View getView(int position, View convertView, ViewGroup
parent) {
                View v = convertView;
                FilmDetail o = items.get(position);
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.cinema_row, null);
                }
                if (o != null) {
                        TextView tt = (TextView) v.findViewById
(R.id.text1);
                        TextView genre = (TextView) v.findViewById
(R.id.genre);
                        TextView directors = (TextView) v.findViewById
(R.id.regisseur);
                        TextView actors = (TextView) v.findViewById
(R.id.acteurs);
                        TextView votes = (TextView) v.findViewById
(R.id.votes);
                        ImageView imgCinema = (ImageView)
v.findViewById(R.id.imgCinema);
                        RatingBar cinemaRating = (RatingBar)
v.findViewById(R.id.cinemarating);
                        if (tt != null)
                        {
                           tt.setText(o.getTitle() + " (" + o.getYear
() + ")");
                        }
                        if (genre !=null)
                        {
                                if (o.getDuration().equals("0"))
                                {
                                        genre.setText(o.getGenres_text());
                                }
                                else{
                                        genre.setText(o.getGenres_text() + ", " +
o.getDuration() + " minuten");
                                }
                        }
                        if (directors != null)
                        {
                         ...
read more »
Wouter
2009-09-18 17:00:49 UTC
Permalink
This is the function:

public View getView(int position, View convertView, ViewGroup parent)
{
int sectionnum = 0;
for(Object section : this.sections.keySet()) {
Adapter adapter = sections.get(section);
int size = adapter.getCount() + 1;

// check if position inside this section
if(position == 0) return headers.getView(sectionnum, convertView,
parent);
if(position < size) return adapter.getView(position - 1,
convertView, parent);

// otherwise jump into next section
position -= size;
sectionnum++;
}
return null;
}

93: --> if(position == 0) return headers.getView(sectionnum,
convertView, parent);

resource file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent"
<ImageView android:id="@+id/imgCinema"
android:layout_width="60px"
android:layout_margin="5px"
android:src="@drawable/icon"
android:layout_height="80px">
</ImageView>

<LinearLayout
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent"
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="16px"
android:textStyle="bold"
android:text="FilmTitle"/>

<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<RatingBar android:id="@+id/cinemarating"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/votes"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12px"
android:text="votes"/>
</LinearLayout>
<TextView
android:id="@+id/genre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12px"
android:text="genre"/>
<TextView
android:id="@+id/regisseur"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12px"
android:text="regisseur"/>
<TextView
android:id="@+id/acteurs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="12px"
android:text="acteurs"/>

</LinearLayout>

</LinearLayout>

But without this seperatedlistadapter it is working (was working
before with it too). So don't know what problem is..

hope you can help me!

Wouter
Post by Yusuf Saib (T-Mobile USA)
Where in your code is SeparatedListAdapter.java:93? And can you post
the resource xml as well?
Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.
Post by Wouter
I removed my seperatedlistadapter and now it worked.. :s But it was
working before with my seperatedlistadapter :(
Post by Wouter
Really dont find what the problem is, the weird is it worked and i
havent changed anything :(
Post by Wouter
Hey,
I have a weird problem. For days i have a working list with movie
details i get from an xml rpc source. It loads the list very well and
I tried it again today and when i scroll down, always at the same list
item it gives me this error. I don't know what the problem is. It
shows my list items very good and now not anymore. If you want i can
give you my source code too! And it worked a few days ago and now
suddenty not :(
09-18 11:50:00.940: ERROR/ArrayAdapter(1561): You must supply a
resource ID for a TextView
09-18 11:50:00.950: DEBUG/AndroidRuntime(1561): Shutting down VM
09-18 11:50:00.950: WARN/dalvikvm(1561): threadid=3: thread exiting
with uncaught exception (group=0x4001aa28)
thread main exiting due to uncaught exception
java.lang.IllegalStateException: ArrayAdapter requires the resource ID
to be a TextView
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
347)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.moviemeter.SeparatedListAdapter.getView
(SeparatedListAdapter.java:93)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.AbsListView.obtainView(AbsListView.java:1255)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.addViewBelow(ListView.java:2795)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.scrollListItemsBy(ListView.java:2725)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScrollImpl(ListView.java:2225)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScroll(ListView.java:2172)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.commonKey(ListView.java:1977)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.onKeyDown(ListView.java:1924)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.KeyEvent.dispatch(KeyEvent.java:893)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.View.dispatchKeyEvent(View.java:3647)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:744)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.dispatchKeyEvent(ListView.java:1909)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.TabHost.dispatchKeyEvent(TabHost.java:272)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
2329)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2299)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1621)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Looper.loop(Looper.java:123)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.ActivityThread.main(ActivityThread.java:4203)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
java.lang.reflect.Method.invoke(Method.java:521)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
dalvik.system.NativeStart.main(Native Method)
java.lang.ClassCastException: android.widget.LinearLayout
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
340)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     ... 40 more
This is my cinemaAdapter class for making my list!
 private class cinemaAdapter extends ArrayAdapter<FilmDetail> {
        private List<FilmDetail> items;
        public cinemaAdapter(Context context, List<FilmDetail> films)
{
                super(context, R.layout.cinema_row, films);
                this.items = films;
        }
        public View getView(int position, View convertView, ViewGroup
parent) {
                View v = convertView;
                FilmDetail o = items.get(position);
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater)
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    v = vi.inflate(R.layout.cinema_row, null);
                }
                if (o != null) {
                        TextView tt = (TextView) v.findViewById
(R.id.text1);
                        TextView genre = (TextView) v.findViewById
(R.id.genre);
                        TextView directors = (TextView) v.findViewById
(R.id.regisseur);
                        TextView actors = (TextView) v.findViewById
(R.id.acteurs);
                        TextView votes = (TextView) v.findViewById
(R.id.votes);
                        ImageView imgCinema = (ImageView)
v.findViewById(R.id.imgCinema);
                        RatingBar cinemaRating = (RatingBar)
v.findViewById(R.id.cinemarating);
                        if (tt != null)
                        {
                           tt.setText(o.getTitle() + " (" + o.getYear
() + ")");
                        }
                        if (genre !=null)
                        {
                     
...
meer lezen »
Wouter
2009-09-19 13:10:14 UTC
Permalink
Do you know a solution?
Post by Wouter
public View getView(int position, View convertView, ViewGroup parent)
{
                int sectionnum = 0;
                for(Object section : this.sections.keySet()) {
                        Adapter adapter = sections.get(section);
                        int size = adapter.getCount() + 1;
                        // check if position inside this section
                        if(position == 0) return headers.getView(sectionnum, convertView,
parent);
                        if(position < size) return adapter.getView(position - 1,
convertView, parent);
                        // otherwise jump into next section
                        position -= size;
                        sectionnum++;
                }
                return null;
        }
93: --> if(position == 0) return headers.getView(sectionnum,
convertView, parent);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
     android:layout_width="60px"
     android:layout_margin="5px"
      android:layout_height="80px">
    </ImageView>
<LinearLayout
        android:orientation="vertical" android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="16px"
    android:textStyle="bold"
    android:text="FilmTitle"/>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
            style="?android:attr/ratingBarStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical" />
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
        android:textSize="12px"
    android:text="votes"/>
    </LinearLayout>
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
        android:textSize="12px"
    android:text="genre"/>
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
        android:textSize="12px"
    android:text="regisseur"/>
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
            android:textSize="12px"
    android:text="acteurs"/>
</LinearLayout>
</LinearLayout>
But without this seperatedlistadapter it is working (was working
before with it too). So don't know what problem is..
hope you can help me!
Wouter
Post by Yusuf Saib (T-Mobile USA)
Where in your code is SeparatedListAdapter.java:93? And can you post
the resource xml as well?
Yusuf Saib
Android
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.
Post by Wouter
I removed my seperatedlistadapter and now it worked.. :s But it was
working before with my seperatedlistadapter :(
Post by Wouter
Really dont find what the problem is, the weird is it worked and i
havent changed anything :(
Post by Wouter
Hey,
I have a weird problem. For days i have a working list with movie
details i get from an xml rpc source. It loads the list very well and
I tried it again today and when i scroll down, always at the same list
item it gives me this error. I don't know what the problem is. It
shows my list items very good and now not anymore. If you want i can
give you my source code too! And it worked a few days ago and now
suddenty not :(
09-18 11:50:00.940: ERROR/ArrayAdapter(1561): You must supply a
resource ID for a TextView
09-18 11:50:00.950: DEBUG/AndroidRuntime(1561): Shutting down VM
09-18 11:50:00.950: WARN/dalvikvm(1561): threadid=3: thread exiting
with uncaught exception (group=0x4001aa28)
thread main exiting due to uncaught exception
java.lang.IllegalStateException: ArrayAdapter requires the resource ID
to be a TextView
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
347)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ArrayAdapter.getView(ArrayAdapter.java:323)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.moviemeter.SeparatedListAdapter.getView
(SeparatedListAdapter.java:93)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.AbsListView.obtainView(AbsListView.java:1255)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.addViewBelow(ListView.java:2795)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.scrollListItemsBy(ListView.java:2725)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScrollImpl(ListView.java:2225)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.arrowScroll(ListView.java:2172)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.commonKey(ListView.java:1977)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.onKeyDown(ListView.java:1924)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.KeyEvent.dispatch(KeyEvent.java:893)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.View.dispatchKeyEvent(View.java:3647)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:744)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.ListView.dispatchKeyEvent(ListView.java:1909)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.widget.TabHost.dispatchKeyEvent(TabHost.java:272)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:746)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow
$DecorView.superDispatchKeyEvent(PhoneWindow.java:1708)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent
(PhoneWindow.java:1197)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.Activity.dispatchKeyEvent(Activity.java:1967)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
2329)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2299)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1621)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Handler.dispatchMessage(Handler.java:99)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.os.Looper.loop(Looper.java:123)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
android.app.ActivityThread.main(ActivityThread.java:4203)
09-18 11:50:00.990: ERROR/AndroidRuntime(1561):     at
...
meer lezen »
purvi
2009-10-07 14:18:22 UTC
Permalink
Hi,

I had the same problem, it was gone when i removed all the @override
lines above the functions of the SeparateListAdapter.
So try not overriding the functions.
It worked for me.

Regards,
Purvi
But I declare it there and then in my runnable i do
adapter.notifyDatasetChanged so the listview knows there is other data
to show.
This works for other adapters.. Really don't know why this isn't
working.
My listview with headers works, i can see the first header or
sometimes more but when i scroll down it crashes.. When i do for
example
adapter.addSection("test", new cinemaAdapter(this, cinema)); it makes
1 list with 1 header without crashing..
So there must be a problem with generating my header titles :s
I don't see anything obviously wrong with your code. I do notice that
you apparently create the SeparatedListAdapter and then immediately
call setListAdapter with it, whereas the SeparatedListAdapter sample
code creates the adapter, then adds a bunch of sections to it, and
then calls setListAdapter at the end. Could it be that
SeparatedListAdapter doesn't work when it is empty? Have you tried
postponing your call to setListAdapter until after you've added all
the sections?
Ok i will try to explain how i generate my headers with the
seperatedlistadapter..
private SeparatedListAdapter adapter;
this.adapter = new SeparatedListAdapter(this);
setListAdapter(adapter);
       public void retrieveCinema()
   {
       try {
                       HashMap<String, Object> response = (HashMap<String, Object>)
client.call("film.retrieveCinema", sessionKey);
                       Comparator reverse = Collections.reverseOrder();
                       TreeMap<String, Object> result = new TreeMap<String, Object>
(reverse);
                       TreeMap<String, Object> sortedMap = new TreeMap<String, Object>
(response);
                       result.putAll(sortedMap);
                       Iterator it = result.entrySet().iterator();
                   while (it.hasNext()) {
                       cinema = new ArrayList<FilmDetail>();
                       Map.Entry pairs = (Map.Entry)it.next();
                       Object[] cinemaFilms = (Object[])pairs.getValue();
                       FilmDetail cinemaMovie = new FilmDetail();
                       for (int i=0; i<cinemaFilms.length; i++)
                       {
                       cinemaMovie = new FilmDetail();
                       Map m = (Map) cinemaFilms[i];
                       cinemaMovie.setTitle(m.get("title").toString());
                       cinemaMovie.setYear(m.get("year").toString());
                       cinemaMovie.setVotes_count(m.get("votes_count").toString());
                       cinemaMovie.setActors_text(m.get("actors_text").toString());
                       cinemaMovie.setDirectors_text(m.get
("directors_text").toString());
                       cinemaMovie.setGenres_text(m.get("genres_text").toString());
                       cinemaMovie.setAverage(m.get("average").toString());
                       cinemaMovie.setFilmId(m.get("filmId").toString());
                       cinemaMovie.setDuration(m.get("duration").toString());
                       cinema.add(cinemaMovie);
                       }
                       String datum = pairs.getKey().toString();
                       SimpleDateFormat formatter = new SimpleDateFormat("EEEEEE d
MMMMMM");
                       formatter.applyLocalizedPattern("EEEEEE d MMMMMM");
                       int year= Integer.valueOf(datum.substring(0,4));
                       int month = Integer.valueOf(datum.substring(5,7));
                       int day = Integer.valueOf(datum.substring(8,10));
                       java.util.Date date = new java.util.Date(year, month, day);
                       String parsed = formatter.format(date);
                       System.out.println(parsed);
                       adapter.addSection(parsed, new cinemaAdapter(this, cinema));
                   }
               } catch (XMLRPCException e) {
                       e.printStackTrace();
               }
               runOnUiThread(returnRes);
   }
And for every date in my response i do this
adapter.addSection(parsed, new cinemaAdapter(this, cinema));
and parsed is the parsed text from date (example 31 october))
And this is how i generate it!
 It there an error somewhere?
#     public void onCreate(Bundle icicle) {
#         super.onCreate(icicle);
#
#         List<Map<String,?>> security = new LinkedList<Map<String,?>>
();
#         security.add(createItem("Remember passwords", "Save
usernames and passwords for Web sites"));
#         security.add(createItem("Clear passwords", "Save usernames
and passwords for Web sites"));
#         security.add(createItem("Show security warnings", "Show
warning if there is a problem with a site's security"));
#
#         // create our list and custom adapter
#         SeparatedListAdapter adapter = new SeparatedListAdapter
(this);
#         adapter.addSection("Array test", new ArrayAdapter<String>
(this,
#             R.layout.list_item, new String[] { "First item", "Item
two" }));
#         adapter.addSection("Security", new SimpleAdapter(this,
security, R.layout.list_complex,
#             new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[]
{ R.id.list_complex_title, R.id.list_complex_caption }));
#
#         ListView list = new ListView(this);
#         list.setAdapter(adapter);
#         this.setContentView(list);
#
#     }
so every section is using a different layout file. So why doestn't
this work with me? :(
The specific crash you're seeing is caused by the wrong layout being
used for a list item, that much is clear from the log. It's hard to
say whether this is because you're using this SeparatedListAdapter
wrong, or because there's a bug in it. With SeparatedListAdapter
you're actually using multiple adapters (one for each section, and one
for all the section-headers), which makes it a little harder to debug.
You could start by adding lots of logging, so you can see what
position it's trying to get a view for, what section and layout it
thinks that position corresponds to and then check whether that layout
actually has all the fields that that section's adapter needs.
On thing that's a bit suspicious about the code you've posted so far
is that you appear to be assigning values (data) to the various views
in your getView(), which is not what you would normally do. Normally
getView only returns a layout of the correct type, and the adapter
itself then assigns the data from the array or Cursor to the various
views in your layout.
You are also assigning values to a lot of the child views of that
layout (all of those calls to setText). On second thought I don't
think that is actually the problem though.
Given where it crashed, the problem is with the adapter you specified
for the section headers, which if I understand correctly is not
cinemaAdapter, but some other adapter (possibly a plain ArrayAdapter)
that displays dates. If you post the code for that (how do you create
it), we can probably sort this out.- Hide quoted text -
- Show quoted text -
Wouter
2009-10-07 14:24:53 UTC
Permalink
Could it be that simple? Gonna try it immediatelly!

Thank you!
Post by purvi
Hi,
lines above the functions of the SeparateListAdapter.
So try not overriding the functions.
It worked for me.
Regards,
Purvi
But I declare it there and then in my runnable i do
adapter.notifyDatasetChanged so the listview knows there is other data
to show.
This works for other adapters.. Really don't know why this isn't
working.
My listview with headers works, i can see the first header or
sometimes more but when i scroll down it crashes.. When i do for
example
adapter.addSection("test", new cinemaAdapter(this, cinema)); it makes
1 list with 1 header without crashing..
So there must be a problem with generating my header titles :s
I don't see anything obviously wrong with your code. I do notice that
you apparently create the SeparatedListAdapter and then immediately
call setListAdapter with it, whereas the SeparatedListAdapter sample
code creates the adapter, then adds a bunch of sections to it, and
then calls setListAdapter at the end. Could it be that
SeparatedListAdapter doesn't work when it is empty? Have you tried
postponing your call to setListAdapter until after you've added all
the sections?
Ok i will try to explain how i generate my headers with the
seperatedlistadapter..
private SeparatedListAdapter adapter;
this.adapter = new SeparatedListAdapter(this);
setListAdapter(adapter);
       public void retrieveCinema()
   {
       try {
                       HashMap<String, Object> response = (HashMap<String, Object>)
client.call("film.retrieveCinema", sessionKey);
                       Comparator reverse = Collections.reverseOrder();
                       TreeMap<String, Object> result = new TreeMap<String, Object>
(reverse);
                       TreeMap<String, Object> sortedMap = new TreeMap<String, Object>
(response);
                       result.putAll(sortedMap);
                       Iterator it = result.entrySet().iterator();
                   while (it.hasNext()) {
                       cinema = new ArrayList<FilmDetail>();
                       Map.Entry pairs = (Map.Entry)it.next();
                       Object[] cinemaFilms = (Object[])pairs.getValue();
                       FilmDetail cinemaMovie = new FilmDetail();
                       for (int i=0; i<cinemaFilms.length; i++)
                       {
                       cinemaMovie = new FilmDetail();
                       Map m = (Map) cinemaFilms[i];
                       cinemaMovie.setTitle(m.get("title").toString());
                       cinemaMovie.setYear(m.get("year").toString());
                       cinemaMovie.setVotes_count(m.get("votes_count").toString());
                       cinemaMovie.setActors_text(m.get("actors_text").toString());
                       cinemaMovie.setDirectors_text(m.get
("directors_text").toString());
                       cinemaMovie.setGenres_text(m.get("genres_text").toString());
                       cinemaMovie.setAverage(m.get("average").toString());
                       cinemaMovie.setFilmId(m.get("filmId").toString());
                       cinemaMovie.setDuration(m.get("duration").toString());
                       cinema.add(cinemaMovie);
                       }
                       String datum = pairs.getKey().toString();
                       SimpleDateFormat formatter = new SimpleDateFormat("EEEEEE d
MMMMMM");
                       formatter.applyLocalizedPattern("EEEEEE d MMMMMM");
                       int year= Integer.valueOf(datum.substring(0,4));
                       int month = Integer.valueOf(datum.substring(5,7));
                       int day = Integer.valueOf(datum.substring(8,10));
                       java.util.Date date = new java.util.Date(year, month, day);
                       String parsed = formatter.format(date);
                       System.out.println(parsed);
                       adapter.addSection(parsed, new cinemaAdapter(this, cinema));
                   }
               } catch (XMLRPCException e) {
                       e.printStackTrace();
               }
               runOnUiThread(returnRes);
   }
And for every date in my response i do this
adapter.addSection(parsed, new cinemaAdapter(this, cinema));
and parsed is the parsed text from date (example 31 october))
And this is how i generate it!
 It there an error somewhere?
#     public void onCreate(Bundle icicle) {
#         super.onCreate(icicle);
#
#         List<Map<String,?>> security = new LinkedList<Map<String,?>>
();
#         security.add(createItem("Remember passwords", "Save
usernames and passwords for Web sites"));
#         security.add(createItem("Clear passwords", "Save usernames
and passwords for Web sites"));
#         security.add(createItem("Show security warnings", "Show
warning if there is a problem with a site's security"));
#
#         // create our list and custom adapter
#         SeparatedListAdapter adapter = new SeparatedListAdapter
(this);
#         adapter.addSection("Array test", new ArrayAdapter<String>
(this,
#             R.layout.list_item, new String[] { "First item", "Item
two" }));
#         adapter.addSection("Security", new SimpleAdapter(this,
security, R.layout.list_complex,
#             new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[]
{ R.id.list_complex_title, R.id.list_complex_caption }));
#
#         ListView list = new ListView(this);
#         list.setAdapter(adapter);
#         this.setContentView(list);
#
#     }
so every section is using a different layout file. So why doestn't
this work with me? :(
The specific crash you're seeing is caused by the wrong layout being
used for a list item, that much is clear from the log. It's hard to
say whether this is because you're using this SeparatedListAdapter
wrong, or because there's a bug in it. With SeparatedListAdapter
you're actually using multiple adapters (one for each section, and one
for all the section-headers), which makes it a little harder to debug.
You could start by adding lots of logging, so you can see what
position it's trying to get a view for, what section and layout it
thinks that position corresponds to and then check whether that layout
actually has all the fields that that section's adapter needs.
On thing that's a bit suspicious about the code you've posted so far
is that you appear to be assigning values (data) to the various views
in your getView(), which is not what you would normally do. Normally
getView only returns a layout of the correct type, and the adapter
itself then assigns the data from the array or Cursor to the various
views in your layout.
You are also assigning values to a lot of the child views of that
layout (all of those calls to setText). On second thought I don't
think that is actually the problem though.
Given where it crashed, the problem is with the adapter you specified
for the section headers, which if I understand correctly is not
cinemaAdapter, but some other adapter (possibly a plain ArrayAdapter)
that displays dates. If you post the code for that (how do you create
it), we can probably sort this out.- Hide quoted text -
- Show quoted text -
Wouter
2009-10-07 16:03:41 UTC
Permalink
How can i solve this please?

Wouter
2009-10-07 14:26:24 UTC
Permalink
Post by purvi
Hi,
lines above the functions of the SeparateListAdapter.
So try not overriding the functions.
It worked for me.
Regards,
Purvi
But I declare it there and then in my runnable i do
adapter.notifyDatasetChanged so the listview knows there is other data
to show.
This works for other adapters.. Really don't know why this isn't
working.
My listview with headers works, i can see the first header or
sometimes more but when i scroll down it crashes.. When i do for
example
adapter.addSection("test", new cinemaAdapter(this, cinema)); it makes
1 list with 1 header without crashing..
So there must be a problem with generating my header titles :s
I don't see anything obviously wrong with your code. I do notice that
you apparently create the SeparatedListAdapter and then immediately
call setListAdapter with it, whereas the SeparatedListAdapter sample
code creates the adapter, then adds a bunch of sections to it, and
then calls setListAdapter at the end. Could it be that
SeparatedListAdapter doesn't work when it is empty? Have you tried
postponing your call to setListAdapter until after you've added all
the sections?
Ok i will try to explain how i generate my headers with the
seperatedlistadapter..
private SeparatedListAdapter adapter;
this.adapter = new SeparatedListAdapter(this);
setListAdapter(adapter);
       public void retrieveCinema()
   {
       try {
                       HashMap<String, Object> response = (HashMap<String, Object>)
client.call("film.retrieveCinema", sessionKey);
                       Comparator reverse = Collections.reverseOrder();
                       TreeMap<String, Object> result = new TreeMap<String, Object>
(reverse);
                       TreeMap<String, Object> sortedMap = new TreeMap<String, Object>
(response);
                       result.putAll(sortedMap);
                       Iterator it = result.entrySet().iterator();
                   while (it.hasNext()) {
                       cinema = new ArrayList<FilmDetail>();
                       Map.Entry pairs = (Map.Entry)it.next();
                       Object[] cinemaFilms = (Object[])pairs.getValue();
                       FilmDetail cinemaMovie = new FilmDetail();
                       for (int i=0; i<cinemaFilms.length; i++)
                       {
                       cinemaMovie = new FilmDetail();
                       Map m = (Map) cinemaFilms[i];
                       cinemaMovie.setTitle(m.get("title").toString());
                       cinemaMovie.setYear(m.get("year").toString());
                       cinemaMovie.setVotes_count(m.get("votes_count").toString());
                       cinemaMovie.setActors_text(m.get("actors_text").toString());
                       cinemaMovie.setDirectors_text(m.get
("directors_text").toString());
                       cinemaMovie.setGenres_text(m.get("genres_text").toString());
                       cinemaMovie.setAverage(m.get("average").toString());
                       cinemaMovie.setFilmId(m.get("filmId").toString());
                       cinemaMovie.setDuration(m.get("duration").toString());
                       cinema.add(cinemaMovie);
                       }
                       String datum = pairs.getKey().toString();
                       SimpleDateFormat formatter = new SimpleDateFormat("EEEEEE d
MMMMMM");
                       formatter.applyLocalizedPattern("EEEEEE d MMMMMM");
                       int year= Integer.valueOf(datum.substring(0,4));
                       int month = Integer.valueOf(datum.substring(5,7));
                       int day = Integer.valueOf(datum.substring(8,10));
                       java.util.Date date = new java.util.Date(year, month, day);
                       String parsed = formatter.format(date);
                       System.out.println(parsed);
                       adapter.addSection(parsed, new cinemaAdapter(this, cinema));
                   }
               } catch (XMLRPCException e) {
                       e.printStackTrace();
               }
               runOnUiThread(returnRes);
   }
And for every date in my response i do this
adapter.addSection(parsed, new cinemaAdapter(this, cinema));
and parsed is the parsed text from date (example 31 october))
And this is how i generate it!
 It there an error somewhere?
#     public void onCreate(Bundle icicle) {
#         super.onCreate(icicle);
#
#         List<Map<String,?>> security = new LinkedList<Map<String,?>>
();
#         security.add(createItem("Remember passwords", "Save
usernames and passwords for Web sites"));
#         security.add(createItem("Clear passwords", "Save usernames
and passwords for Web sites"));
#         security.add(createItem("Show security warnings", "Show
warning if there is a problem with a site's security"));
#
#         // create our list and custom adapter
#         SeparatedListAdapter adapter = new SeparatedListAdapter
(this);
#         adapter.addSection("Array test", new ArrayAdapter<String>
(this,
#             R.layout.list_item, new String[] { "First item", "Item
two" }));
#         adapter.addSection("Security", new SimpleAdapter(this,
security, R.layout.list_complex,
#             new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[]
{ R.id.list_complex_title, R.id.list_complex_caption }));
#
#         ListView list = new ListView(this);
#         list.setAdapter(adapter);
#         this.setContentView(list);
#
#     }
so every section is using a different layout file. So why doestn't
this work with me? :(
The specific crash you're seeing is caused by the wrong layout being
used for a list item, that much is clear from the log. It's hard to
say whether this is because you're using this SeparatedListAdapter
wrong, or because there's a bug in it. With SeparatedListAdapter
you're actually using multiple adapters (one for each section, and one
for all the section-headers), which makes it a little harder to debug.
You could start by adding lots of logging, so you can see what
position it's trying to get a view for, what section and layout it
thinks that position corresponds to and then check whether that layout
actually has all the fields that that section's adapter needs.
On thing that's a bit suspicious about the code you've posted so far
is that you appear to be assigning values (data) to the various views
in your getView(), which is not what you would normally do. Normally
getView only returns a layout of the correct type, and the adapter
itself then assigns the data from the array or Cursor to the various
views in your layout.
You are also assigning values to a lot of the child views of that
layout (all of those calls to setText). On second thought I don't
think that is actually the problem though.
Given where it crashed, the problem is with the adapter you specified
for the section headers, which if I understand correctly is not
cinemaAdapter, but some other adapter (possibly a plain ArrayAdapter)
that displays dates. If you post the code for that (how do you create
it), we can probably sort this out.- Hide quoted text -
- Show quoted text -
Loading...