Prompt, the first suitable record from the database is inserted into the desired TextView , when the svayp should be inserted the next record in the TextView in the new item, but in fact the first one is duplicated.

I'll use this one https://github.com/Diolor/Swipecards

 public class CardActivity extends AppCompatActivity { SimpleCursorAdapter simpleCursorAdapter; Cursor cursor; SQLiteDatabase db; DBHelper dbHelper; String[] selectionArgs = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_card); SwipeFlingAdapterView flingContainer = (SwipeFlingAdapterView) findViewById(R.id.frame); dbHelper = new DBHelper(this); db = dbHelper.getReadableDatabase(); Intent intent1 = getIntent(); selectionArgs = intent1.getStringArrayExtra("selection_args"); //String[] selectionArgs = {"food"}; String [] colForQuery = new String[] {"_id","col_rus"}; cursor = db.query("my_table",colForQuery,"col_category =?",selectionArgs,null,null,null); String[] stringFrom = new String[]{DBHelper.COL_RUS} ; int[] to = new int[]{R.id.helloText}; simpleCursorAdapter = new SimpleCursorAdapter(this,R.layout.item,cursor,stringFrom,to); flingContainer.setAdapter(simpleCursorAdapter); flingContainer.setFlingListener(new SwipeFlingAdapterView.onFlingListener() { @Override public void removeFirstObjectInAdapter() { } @Override public void onLeftCardExit(Object dataObject) { Toast.makeText(CardActivity.this, "Left!", Toast.LENGTH_SHORT).show(); } @Override public void onRightCardExit(Object dataObject) { Toast.makeText(CardActivity.this, "Right!", Toast.LENGTH_SHORT).show(); } @Override public void onAdapterAboutToEmpty(int itemsInAdapter) { } @Override public void onScroll(float v) { } }); flingContainer.setOnItemClickListener(new SwipeFlingAdapterView.OnItemClickListener() { @Override public void onItemClicked(int itemPosition, Object dataObject) { Toast.makeText(CardActivity.this, "Clicked!",Toast.LENGTH_LONG).show(); } }); } } 

    1 answer 1

    try after the swipe, in the same place where the Toast is, add

     notifyDataSetChanged(); 
    • Tried, did not help - xebeche
    • It seems to me what it means, you need to get rid of the array, because it cannot delete elements and use an ArrayList, just like in the sample - AndrewGrow
    • Yes, that's how it turned out! Thank you) - xebeche