Long list - need 'Contacts' scrollbar

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Long list - need 'Contacts' scrollbar

Postby iaindownie » Thu Dec 31, 2009 11:49 am

Hi,
I have a long list in ListView (about 550 species names), and have two questions relating to this code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class CommonCodes extends Activity {
  2.  
  3.         /** Called when the activity is first created. */
  4.  
  5.  
  6.  
  7.         @Override
  8.  
  9.         public void onCreate(Bundle savedInstanceState) {
  10.  
  11.                 super.onCreate(savedInstanceState);
  12.  
  13.                 setContentView(R.layout.main); // bind the layout to the activity
  14.  
  15.                 ListView lv = (ListView) findViewById(R.id.ListView01);
  16.  
  17.                 ListAdapter birds = (ListAdapter) ArrayAdapter.createFromResource(this,
  18.  
  19.                                 R.array.species, android.R.layout.simple_list_item_1);
  20.  
  21.                 lv.setAdapter(birds);
  22.  
  23.                 lv.setTextFilterEnabled(true);
  24.  
  25.         }
  26.  
  27. }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


<RelativeLayout android:id="@+id/RelativeLayout01"
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.         android:layout_width="fill_parent" android:layout_height="fill_parent"
  2.  
  3.         xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.         android:background="@color/darkGrey">
  6.  
  7.         <TextView android:id="@+id/helptext" android:layout_width="fill_parent"
  8.  
  9.                 android:layout_height="wrap_content"
  10.  
  11.                 android:text=" Scroll or type name to find species (BOU order)"
  12.  
  13.                 android:layout_below="@+id/appname" android:background="@color/darkGreen" />
  14.  
  15.         <ListView android:id="@+id/ListView01" android:layout_width="wrap_content"
  16.  
  17.                 android:layout_height="wrap_content" android:layout_below="@+id/helptext"
  18.  
  19.                 android:background="@color/darkGrey" />
  20.  
  21. </RelativeLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


1. I use setTextFilterEnabled(true) so that folk can start typing the species name. This seems easy on a G1 (my phone), but how will users invoke the keyboard on a newer phone with no physical keyboard? Do they have a special button?

2. It's a huge list - you can scroll through it, but it takes ages - I want to use the same type of 'thumb' scroll bar that appears when I scroll through my contacts. Any ideas on how to use this? One problem is that the species are in non-alphabetic order, but I would be happy to make it alphabetic if necessary.

Thanks
Iain
User avatar
iaindownie
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Mon Dec 29, 2008 4:08 pm
Location: Thetford, Norfolk, UK

Top

Postby achie1266 » Thu Dec 31, 2009 6:47 pm

you may have to provide them a search option probably in your OptionstMenu, just like it is done in the contacts app. Or maybe provide a searchBox at the top/bottom of the layout and use Filter to filter the list as they type. You may have to extend the Filter Class.

And for your second question you said that you have many items and its taking a long time to scroll them. But it will not take such a long time if you use a viewHolder and reuse the views as they disappear from the list. That way the listView will always take the same time for displaying the list no matter how many listItems it has. Here is an examplehttp://developer.android.com/gui ... ist14.html

I never worked on customizing scrollbars and do not know what you mean by thumb scroll bar. But there are options to customize the scrollbar in the ListView Class that you may want to look at.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby iaindownie » Fri Jan 08, 2010 2:42 pm

Thanks, I'll have a look at all these ideas. For info, the thumb scrollbar thing I refer to appears when you scroll through your Contacts on the G1 - but this is the only place I've seen it.

Iain
User avatar
iaindownie
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Mon Dec 29, 2008 4:08 pm
Location: Thetford, Norfolk, UK

Postby achie1266 » Wed Jan 13, 2010 12:15 am

hmm now I know what you meant..I just saw that on my nexus one.

Did you happen to figure out how to get that?
I would like to know how to implement that.

Thank you.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby achie1266 » Wed Jan 13, 2010 1:09 am

hey this was actually solved by qlimax and he posted a tutorial for that here
http://www.anddev.org/tutalphabetic_fas ... 10123.html

this should help you.
I tried it too and it does display the thumb scroll thing with the alphabets like in the contacts app.
achie
User avatar
achie1266
Master Developer
Master Developer
 
Posts: 223
Joined: Mon Nov 09, 2009 10:56 pm
Location: Denver

Postby Droid123 » Tue Jan 26, 2010 6:07 pm

achie1266 wrote:hey this was actually solved by qlimax and he posted a tutorial for that here
tutalphabetic_fastscroll_listview_-_similar_to_contacts-t10123.html

this should help you.
I tried it too and it does display the thumb scroll thing with the alphabets like in the contacts app.


Do you know if it's possible to display the thumb scroll thing in shorter lists ( < 200 items) ? I need a way to goto a position in the list, by clicking on the scrollbar. (like in windows)
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Top

Postby jwei512 » Wed Jan 27, 2010 12:07 am

are you talking about enabling android:fastScrollEnabled = "true" in the layout XML?
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Postby Droid123 » Wed Jan 27, 2010 10:16 am

jwei512 wrote:are you talking about enabling android:fastScrollEnabled = "true" in the layout XML?


maybe... Is that all that is required to get the thumb-scroller-thing?
Droid123
Experienced Developer
Experienced Developer
 
Posts: 77
Joined: Sat Nov 21, 2009 1:21 pm

Postby jwei512 » Wed Jan 27, 2010 12:03 pm

Yea when you set that in the layout for the list view if you start scrolling that big fat scroll bar thing comes up and from there you can click around the scroll bar to manuever quickly in the list
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests