Github链接问题示例:https://github.com/ghost606/TestSwipeListView
我正在使用https://github.com/47deg/android-swipelistview中的SwipeListView
库。但是我的滑动手势非常反应迟钝。
这就是我想要的:
我的问题是手势非常反应迟钝。也许这是我正在使用的库的组合:ActionBarSherlock
,Pull-To-Refresh
和DrawerLayout
。
有人可以帮我解决这个问题吗?
这是我的代码:
MainActivity XML:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/menu_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/white"
android:dividerHeight="2dp"
android:padding="4dp"
android:background="@drawable/border_top" />
</android.support.v4.widget.DrawerLayout>
实现swipelistview和drawerlayout的片段:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="be.appmax.ktsjjt.fragments.BeersListFragment">
<uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ptr_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.fortysevendeg.swipelistview.SwipeListView
xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="@+id/lv_beers"
android:layout_width="match_parent"
android:layout_height="match_parent"
swipe:swipeFrontView="@+id/front"
swipe:swipeBackView="@+id/back"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeActionLeft="choice"
swipe:swipeMode="left"
swipe:swipeOpenOnLongPress="true"
swipe:swipeOffsetLeft="275dp">
</com.fortysevendeg.swipelistview.SwipeListView>
</uk.co.senab.actionbarpulltorefresh.extras.actionbarsherlock.PullToRefreshLayout>
</RelativeLayout>
片段代码:
public class BeersListFragment extends Fragment implements OnRefreshListener {
private BeerAdapter beerAdapter;
private PullToRefreshLayout pullToRefreshLayout;
private SwipeListView listView;
private List<Beer> beers = new ArrayList<Beer>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
beers.addAll(Shared.dbRepo.beerRepository.getAll());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_beers, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
listView = (SwipeListView) view.findViewById(R.id.lv_beers);
pullToRefreshLayout = (PullToRefreshLayout) view.findViewById(R.id.ptr_layout);
beerAdapter = new BeerAdapter(getActivity(), R.layout.row_beer, beers);
listView.setAdapter(beerAdapter);
listView.setSwipeListViewListener(new SwipeListViewHandler());
ActionBarPullToRefresh.from(getActivity())
.allChildrenArePullable()
.listener(this)
.useViewDelegate(ListView.class, new AbsListViewDelegate())
.setup(pullToRefreshLayout);
}
@Override
public void onRefreshStarted(View view) {
//RELOAD EVERYTHING
}
private class SwipeListViewHandler implements SwipeListViewListener {
@Override
public void onOpened(int i, boolean b) {
}
@Override
public void onClosed(int i, boolean b) {
}
@Override
public void onListChanged() {
}
@Override
public void onMove(int i, float v) {
}
@Override
public void onStartOpen(int i, int i2, boolean b) {
}
@Override
public void onStartClose(int i, boolean b) {
}
@Override
public void onClickFrontView(int i) {
Beer beer = beerAdapter.getItem(i);
Tools.startFragment(getActivity(), new BeerDetailFragment(beer), getResources().getString(R.string.title_beer_detail));
}
@Override
public void onClickBackView(int i) {
Beer beer = beerAdapter.getItem(i);
Dialogs dialogs = new Dialogs(getActivity());
dialogs.drinkDialog(new DrinkHandler(getActivity(), beer.getId()), beer.getName());
}
@Override
public void onDismiss(int[] ints) {
}
@Override
public int onChangeSwipeMode(int i) {
return 0;
}
@Override
public void onChoiceChanged(int i, boolean b) {
}
@Override
public void onChoiceStarted() {
}
@Override
public void onChoiceEnded() {
}
@Override
public void onFirstListItem() {
}
@Override
public void onLastListItem() {
}
}
}