Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adapter getCount and listView getChildCount are not equal

I'm trying to set some tests for my android app, and I'm testing that the creation of an entry in the database is displayed in my ListView.

here is some code snippet:

mDbHelper.createAccount();
assertEquals(1, mAccountListAdapter.getCount());
assertEquals(1, mAccountList.getChildCount());

the first assert works fine but in the second, getChildCount return 0.

So the adapter is good, but the listView does not display it?

When I test it manually, the feature works though.

like image 315
Geob-o-matic Avatar asked Jan 30 '26 05:01

Geob-o-matic


1 Answers

mAccountList.getChildCount() refers to the ViewGroup's method that returns the number of the views that this view contains, it's not ListView's method itself. So your assertion is invalid.

like image 157
ernazm Avatar answered Jan 31 '26 17:01

ernazm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!