Hello Romain Guy,
Thax for the reply.
I tried AsyncTask but it works only if i have 10 to 15 elements in my
listview.
if i set my length variable more then 15 in below for loop its giving
out of memory error in eclipse.
Is there any other way i can implement same functionality ?
i tried something like this.
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
for(int i=0;i <= length; i++){
new AddTask().execute(i);
}
}
AddTask Class
private class AddTask extends AsyncTask<Integer, Void, Void> {
TextView textView;
int counter;
protected void onPreExecute() {
textView= (TextView) findViewById(R.id.english);
}
protected Void doInBackground(Integer... params) {
counter = params[0];
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return null;
}
@Override
public void onPostExecute(Void ignore) {
getListView().setSelection(counter);
textView.setText("List View Item " + counter);
}
}
Thax in advance
On May 21, 2:04 pm, Romain Guy <[email protected]> wrote:
> Hi,
>
> You are blocking the UI thread. Basically you are preventing ListView
> from ever doing a layout or a redraw. You should use a Handler or an
> AsyncTask to do this.
>
>
>
> On Wed, May 20, 2009 at 10:01 PM, Freshman <[email protected]> wrote:
>
> > Hi guys,
>
> > I am new to Android I've a ListView.
> > I want to autoscroll all the items of listview on button click event
> > with some specified time interval,
> > and also wants to update the TextView according to selected items.
> > I tried something like this on button click
>
> > for(inti=0;i<=length;i++){
> > getListView().setSelection(i);
> > textview.setText("Hi !" + i);
> > Thread.sleep(1000);
> > }
>
> > After some time It will directly scrolls to last element.
> > And TextView dosen't get updated every time, it'll only shows last
> > element of listview.
>
> > Could you please suggest me any ways to solve this problem ?
>
> > Thanks in advance,
> > freshman
>
> --
> Romain Guy
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time
> to provide private support. All such questions should be posted on
> public forums, where I and others can see and answer them
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---