Friday, July 15, 2011

[android-developers] ListView smoothScrollToPosition question

I've got a pair of ListViews---one is a short "index" to the much
larger list, and, using a switch statement, it passes, via an Intent,
the position that the larger list should move to. It's currently
implemented (for the larger list) like this:

Bundle extras = getIntent().getExtras();
int position = extras.getInt("position");

String[] nameList =
getResources().getStringArray(R.array.grainsName);
ListView mainlist;

mainlist = (ListView)findViewById(R.id.nmList);
mainlist.setOnItemClickListener(this);
mainlist.smoothScrollToPosition(position);

Two questions....

First, is there a way (yes, I've read through the ListView reference)
to jump straight to the intended position, instead of scrolling to it?

Second, when it does scroll to the selected position, it puts it on
the bottom of the display. Is there a way to get it to position it
on the TOP of the display (without knowing how many lines you need
to scroll down to place it there)?

Basically, it's working, it's just a bit ugly.

Thanks,
--jim

--
73 DE N5IAL (/4) MiSTie #49997 < Running FreeBSD 7.0 >
spooky130u@gmail.com ICBM/Hurr.: 30.44406N 86.59909W
Point Lobos Photography Set 1 (Photo-posters): http://jdgapps.com
My policy on spammers:
"Castrate first, ask questions later."

--
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

No comments:

Post a Comment