我正在使用Android SwipeListview,其中我需要显示swipeListview中的一个列表项应该在活动开始时处于打开位置。我使用了以下网站https://github.com/47deg/android-swipelistview中的代码。我在SwipeListView by 47degree: swipe first item programmatically:中也找不到答案,但对我来说没用。请帮帮我,我是它的结构。一些代码供您参考
swipeFrontView = (View) view.findViewById(R.id.front);
if (Build.VERSION.SDK_INT >= 11) {
swipeListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
swipeListView
.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
@Override
public void onItemCheckedStateChanged(ActionMode mode,
int position, long id, boolean checked) {
mode.setTitle("Selected ("
+ swipeListView.getCountSelected() + ")");
}
@Override
public void onDestroyActionMode(ActionMode mode) {
swipeListView.unselectedChoiceStates();
}
@Override
public boolean onActionItemClicked(ActionMode mode,
android.view.MenuItem item) {
return false;
}
@Override
public boolean onCreateActionMode(ActionMode mode,
android.view.Menu menu) {
return false;
}
@Override
public boolean onPrepareActionMode(ActionMode mode,
android.view.Menu menu) {
return false;
}
});
}
swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
@Override
public void onOpened(int position, boolean toRight) {
}
@Override
public void onClosed(int position, boolean fromRight) {
}
@Override
public void onListChanged() {
}
@Override
public void onMove(int position, float x) {
}
@Override
public void onStartOpen(int position, int action, boolean right) {
Log.d("swipe open", String.format("onStartOpen %d - action %d",
position, action));
}
@Override
public void onStartClose(int position, boolean right) {
Log.d("swipe", String.format("onStartClose %d", position));
}
@Override
public void onClickFrontView(int position) {
Log.d("swipe", String.format("onClickFrontView %d", position));
}
@Override
public void onClickBackView(int position) {
Log.d("swipe", String.format("onClickBackView %d", position));
}
@Override
public void onDismiss(int[] reverseSortedPositions) {
/*
* for (int position : reverseSortedPositions) {
* data.remove(position); } adapter.notifyDataSetChanged();
*/
}
});
我用于库包中的动画
private void generateRevealAnimate(final View view) {
ViewPropertyAnimator.animate(view).translationX(700).setDuration(500)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
}
});
}
private void generateCloseAnimate(final View view) {
ViewPropertyAnimator.animate(view).translationX(500).setDuration(500)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
}
});
答案 0 :(得分:0)
尝试listView.openAnimate(int position)
,其中'position'是您想要在活动开始时自动滑动的位置。