Re: [android-developers] Re: ListView getCount is wrong - how do I reset it?

2014-05-17 Thread TreKing
On Sat, May 17, 2014 at 3:11 AM, Doug  wrote:

> Never change the contents of the data in an adapter after you've given it
> to the ListView.
>

Come again? How do you update your UI if not by modifying the adapter data
and notifying it of the change?

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Putting Ads in a keyboard

2014-05-17 Thread Steve Gabrilowitz
I replied on this thread some time ago recommending
http://www.app-bucks.com/ for out of app ads, but my recent experience
compels me to withdraw that recommendation.  eCPM figures continue to
decline and even their representative told me that it isn't going to get
any better.  Too bad, I had high hopes for these guys!

I think that interstitial ads are the way to go these days, and with a bit
of creativity you can incorporate them into an app such as yours, certainly
to have to click past an interstitial every time the keyboard opens would
be excessively annoying but you could keep track of the last time you
displayed an ad and only display 2 or 3 a day, or use a random number
generator to make the ad display at any frequency you choose!


On Tue, Mar 4, 2014 at 2:15 AM, Brill Pappin  wrote:

> So writing keyboards, I work on one of those few apps that actually could
> use things like notification bar ads, however, due to Googles new rules, I
> am left with little choice but to come up with alternatives.
>
> What I've just done is to put a banner ad in a keyboard.
> It *is* pretty awesome in that every time the keyboard pops up, I get an
> impression, but naturally the users hate it and are screaming very loudly
> (and I can't blame them at all).
> I'm not really all that greedy, but I do need to support the apps
> development.
>
> My users are *asking* for the old notification bar ads, but obviously I
> don't want to run afoul of Google rules, so, I am looking for alternative
> ideas on how I might integrate ads into a keyboard.
> I'm willing to experiment with the users a little bit, and I've got a few
> idea from them through support already, but I need to come up with
> something else quickly.
>
> Does anyone have some suggestions I could explore?
>
> FYI - I'm using MoPub because they have an awesome, open source API that
> is very easy to integrate, and works even though I don't have a full
> activity to attach to.
>
> --
> 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] Re: ListView getCount is wrong - how do I reset it?

2014-05-17 Thread Doug


On Friday, May 16, 2014 11:58:17 AM UTC-7, plnelson wrote:
>
> ...In MyListActivity, which is a ListActivity . . .
>
> public static ListView lv;   // my ListView in the code
>

Why is this public and static?
 

> ...the data source is an ArrayList called listItems. The first time around 
> it has 12 items in it; later I clear it and add in 6 items. (see below)
>
> public static ArrayListlistItems=new ArrayList();
>
>
Why is this public and static?
 

> ... in my adapter, which is a BaseAdapter, my override of getCount() looks 
> like this. After shrinking listItems to 6 it correctly returns 6.
>
> @Override
> public int getCount() {
> return listItems.size();
> }
>
> ... To shrink my dataset to 6 I first do a
>
> listItems.clear();
> lv.invalidate();   // my (failed) attempt to get lv to reset its count
>

Invalidate doesn't do what you think it does.  That has to do with the 
rendering of the view on screen, not the contents of the adapter that the 
ListView knows about.
 

> ... and then add in the 6 new items. After adding each item to listItems I 
> do a notifyDataSetChanged() on the adapter. What I've noticed is that if* 
> I do an lv.getCount it returns 12, i.e., the value it was before doing the 
> listItems.clear()* and invalidate(). Why does the ListView still think 
> it's 12? How do I reset it? Is that why the adapter thinks it's too big?
>

Try setting a new (non-public, non-static) adapter into the ListView 
instead.

Never change the contents of the data in an adapter after you've given it 
to the ListView.  Make a deep copy of the data before sending it if you 
have to.

Doug

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.