[android-developers] Re: listview header
There is no problem with the MergeAdapter, I had the same issue in
1.5.
I have tried everything now but nothing works for me :s
On 10 okt, 15:58, Mark Murphy <mmur...@commonsware.com> wrote:
> Wouter wrote:
> > I had uses the MergeAdapter with this code:
>
> > public void retrieveVideotheek()
> > {
> > try {
> > HashMap<String, Object> response = (HashMap<String, Object>)
> > client.call("film.retrieveTv", sessionKey);
>
> > Iterator it = response.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());
> > .....
> > cinema.add(cinemaMovie);
> > }
>
> > String datum = pairs.getKey().toString();
> > long unixTime = Long.parseLong(datum);
> > long timeStamp = unixTime * 1000;
> > java.util.Date date = new Date(timeStamp);
> > SimpleDateFormat formatter = new SimpleDateFormat("EEEEEE,
> > HH:mm 'uur'");
> > String parsed = formatter.format(date);
>
> > System.out.println("DATUM: " + parsed);
>
> > LayoutInflater inflater = (LayoutInflater)
> > this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
> > View filmLayout = inflater.inflate(R.layout.list_header,
> > null);
> > TextView headerTxt = (TextView)filmLayout.findViewById
> > (R.id.list_header_title);
> > headerTxt.setText(parsed);
>
> > mergeAdapter.addView(headerTxt);
> > mergeAdapter.addAdapter(new cinemaAdapter(this,
> > R.layout.cinema_row, cinema));
>
> > //adapter.addSection(parsed, new cinemaAdapter(this,
> > R.layout.cinema_row, cinema));
>
> > }
>
> > and this is the response:
>
> > {1255207800=[Ljava.lang.Object;@43780378, 1255199100=
> > [Ljava.lang.Object;@43824bb8, 1255204800=[Ljava.lang.Object;@4381fd38,
> > 1255212600=[Ljava.lang.Object;@43822ff0, 1255169700=
> > [Ljava.lang.Object;@438289d8, 1255194000=[Ljava.lang.Object;@43796e08,
> > 1255189800=[Ljava.lang.Object;@43819d98, 1255197600=
> > [Ljava.lang.Object;@43824b18, 1255183500=[Ljava.lang.Object;@438147b8,
> > 1255181400=[Ljava.lang.Object;@43859b58, 1255206000=
> > [Ljava.lang.Object;@438189e0, 1255207500=[Ljava.lang.Object;@43790030,
> > 1255212000=[Ljava.lang.Object;@43788908, 1255216500=
> > [Ljava.lang.Object;@43823570}
>
> > So for every key i make a new header with the corresponding Movies
> > under this header.
>
> > When the listActivity loads it shows it very well but when i scroll
> > down and up it shows me this list like this:
>
> >http://snapplr.com/stkn
>
> > What is the problem?
>
> Off the top of my head, I have no idea.
>
> > mergeAdapter.addView(headerTxt);
> > mergeAdapter.addAdapter(new cinemaAdapter(this,
> > R.layout.cinema_row, cinema));
>
> That much seems correct. The rest is your business logic which I only
> sorta follow.
>
> I have not tested MergeAdapter on Android 1.6 (part of my chores for
> this weekend), so there is a chance it needs updating.
>
> Try the demo activity that ships with MergeAdapter and see if it behaves
> properly.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Need Android talent? Ask on HADO!http://wiki.andmob.org/hado
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home