I moved the int countVisible = list1.getChildCount() code to onResume.
However, I still get 0 for getChildCount.
So it looks like onResume event is called before the first layout is
completed.

Do you know which method I should override for getting
list1.getChildCount() to work (IOW which event is called after the
first layout is completed)

On Apr 9, 10:31 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> Because you are calling getChildCount() before the Views are on the
> screen. You must call it after the first layout, when the views are
> visible on screen.
>
>
>
>
>
> On Wed, Apr 9, 2008 at 10:26 PM, Ram <[EMAIL PROTECTED]> wrote:
>
> >  OK, then I'm not sure why the following test code isn't working
>
> >     String[] testArray = new String[30];
> >     ArrayAdapter<String> adapter = new ArrayAdapter<String>(m_context,
> >  R.layout.list_row, R.id.textCol1, testArray);
> >     list1.setAdapter(adapter);
>
> >     int count = list1.getCount();
> >     int countVisible = list1.getChildCount();
>
> >  Xml for the listview is
> >     <ListView android:id="@+id/list1"
> >         android:layout_width="wrap_content"
> >         android:layout_height="0dip"
> >         android:layout_weight="999"
> >     />
>
> >  The listview renders correctly.
> >  I see around 12 entries on the first page ....and I can scroll to see
> >  the other list entries
> >  The value of list1.getCount() is 30. However, list1.getChildCount()
> >  returns 0
> >  I'm using M5-rc14
>
> >  Ram
>
> >  On Apr 9, 10:16 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> >  > As I just said, listView.getChildCount() returns the number of views
> >  > currently displayed on screen by ListView. It has nothing to do with
> >  > the fact that the adapter is bounds by <String>.
>
> > > On Wed, Apr 9, 2008 at 10:13 PM, Ram <[EMAIL PROTECTED]> wrote:
>
> >  > >  I forgot to mention that the listview is bound to
> >  > >  ArrayAdapter<String>.
>
> >  > >  ListView.GetChildCount() returns 0 (presumably, because the list
> >  > >  elements aren't android views. They are strings from the array
> >  > >  adapter.)
>
> >  > >  Do you know how I can find the number of visible strings within the
> >  > >  listbox
>
> >  > >  Thanks Ram
>
> >  > >  On Apr 9, 9:11 pm, "Romain Guy" <[EMAIL PROTECTED]> wrote:
> >  > >  > ListView.getChildCount().
>
> >  > >  > On Wed, Apr 9, 2008 at 9:04 PM, Ram <[EMAIL PROTECTED]> wrote:
>
> >  > >  > >  Hi, ListView.getCount() returns the total number of data items 
> > in the
> >  > >  > >  listview.
>
> >  > >  > >  Does anyone know how to find out the total number of visible 
> > views in
> >  > >  > >  the listbox.
>
> >  > >  > >  Alternately, does anyone know how to see whether the listview 
> > will
> >  > >  > >  scroll or not (i.e. if number of visible views < getCount())
>
> >  > >  > --
> >  > >  > Romain Guywww.curious-creature.org
>
> >  > --
> >  > Romain Guywww.curious-creature.org-Hide quoted text -
>
> >  > - Show quoted text -
>
> --
> Romain Guywww.curious-creature.org- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to