我必须实现刷卡功能,一次刷卡后,当我们进行第二次刷卡时,它将停止工作
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".All_Modules.FindMatch.Search">
<com.tablefortwo.Views.tindercard.SwipeFlingAdapterView
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/trans_grey"
app:rotation_degrees="15.5" />
</androidx.constraintlayout.widget.ConstraintLayout>
这是活动代码
public class Search extends BaseActivity {
@BindView(R.id.frame)
SwipeFlingAdapterView frame;
SwipeFlingAdapterView.onFlingListener onFlingListener;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
ButterKnife.bind(this);
onFlingListener = new SwipeFlingAdapterView.onFlingListener() {
@Override
public void removeFirstObjectInAdapter() {
}
@Override
public void onLeftCardExit(Object dataObject) {
FlingCardListener.FlingListener flingListener = frame.getFlingListener();
flingListener.onCardExited();
}
@Override
public void onRightCardExit(Object dataObject) {
}
@Override
public void onAdapterAboutToEmpty(int itemsInAdapter) {
}
@Override
public void onScroll(float scrollProgressPercent) {
}
};
frame.setFlingListener(onFlingListener);
SearchAdapter adapter = new SearchAdapter(mContext);
frame.setAdapter(adapter);
}
}
这是适配器的代码
public class SearchAdapter extends BaseAdapter {
Context ctx;
public SearchAdapter(Context ctx) {
this.ctx = ctx;
}
@Override
public int getCount() {
return 20;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.card_item, parent, false);
}
return convertView;
}
}
计数在20时是静态的...但是在第一次计数后它停止并且不滑动 进一步,我需要使其像滑动器应用程序功能一样向上滑动到20位
答案 0 :(得分:0)
请在刷卡后也从列表中删除数据,然后通知适配器,这样就可以了。