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
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);
}
}
But it works only if i have 10 to 15 elements in my listview.(for
length = 10 to 15 in above for loop)
if i set my length variable more then 15 in above for loop its giving
out of memory exception.
Is there any other way i can implement same functionality ?
Could anyone Please suggest me any ways to solve this problem ?
Thax in advance,
Freshman
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---