Monday, July 18, 2011

[android-developers] Re: (java.lang.NullPointerException at android.widget.ListView.setupChild(ListView.java:1838))I use listview and BaseAdapter

Thanks for your reply.

I'm working like this.

New a Handler in Activity's onCreate(),and after all things init,I
send msg to Handler on a non-UI thread.When Handler receive a msg,it
update the element or scroll the list by call notifyDataSetChanged and
setSelectionFromTop in Handler's handleMessage(Message msg).

@Override
public void onCreate(Bundle icicle){
super.onCreate(icicle);
.......................
.......................
xxxxxxxxx = new Handler() {
public void handleMessage(Message msg) {
switch(msg.what) {
case xxxxxxxx:{
xxx.notifyDataSetChanged();
}
break;
case xxxxxxxx:{
xxxsetSelectionFromTop (1,20);
}
break;
}
}
}
................
}

In most cases all work well,but sometimes there is the
NullPointerException.

On 7月15日, 上午10时30分, TreKing <trekingapp@gmail.com> wrote:
> On Wed, Jul 13, 2011 at 4:45 AM, zatenoi <zatenoi@gmail.com> wrote:
> > can anyone help me?thanks very much.
>
> Debug your code. In particular make sure you're not manipulating anything in
> the list on a non-UI thread.
>
> --------------------------------------------------------------------------- ----------------------
> TreKing <http://sites.google.com/site/rezmobileapps/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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment