-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the setSelection doest not work #10
Comments
I Have the same problem exactly! |
Same here |
hi, i find a way to solve setSelection. private int mChildWidth;
@Override
public void setSelection(int position) {
if(mChildWidth == 0) {
mChildWidth = getSelectedView().getWidth();
}
int positionX = position * mChildWidth;
if (positionX <= 0) {
positionX = 0;
}
int maxWidth = mAdapter.getCount() * mChildWidth;
if (positionX > maxWidth) {
positionX = maxWidth;
}
scrollTo(positionX);
mCurrentlySelectedAdapterIndex = position;
} |
here are some problem if you use the code above,you will get NullPointException at "getSelectedView()",you can try like this |
I am also getting the null pointer exception with the code posted by @yuxiangping |
Perfectly solved the same problem,thanks! |
After the HorizontalListView init ,I need to locate to the middle of the list , I find the method setSelection but it does not work for me , Then I google how to use it in normal listview . I almost try every way but still now work .I am not sure it is a bug of Android-HorizontalListView .so can you help me . thank you .And forgive my poor Englist.
The text was updated successfully, but these errors were encountered: