I'm using gallery widget with two textView below.
I've added a onItemSelectedListener to change dinamically textView value:
mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3) {
TextView titleView= (TextView) findViewById(R.id.titleView);
TextView descriptionView= (TextView) findViewById(R.id.descriptionView);
titleView.setText(title[position]);
descriptionView.setText(description[position]);
}
But when I flip on the gallery, there is a problem. The animation isn't fluid, if I remove the "setText" statement, works correctly. I've this problem only on Android 4.0.
There is a way to solve it?
I had the same issue some time back.. In my opinion its a bug in The Gallery.. I solved it in a kind of hack´ish way by posting the update 400 ms delayed(the duration for snapback). And set setCallbackDuringFling to false so it won´t fire before it´s stopping.
mGallery.setCallbackDuringFling (false);
mGallery.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long arg3) {
mGallery.postDelayed(new Runnable() {
@Override
public void run() {
TextView titleView= (TextView) findViewById(R.id.titleView);
TextView descriptionView= (TextView) findViewById(R.id.descriptionView);
titleView.setText(title[position]);
descriptionView.setText(description[position]);
}
}, 400);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.