0

Am new to Android and want to use swipe gesture on my table. I am populating my table using an array list from a SQLite DB. On swipe of ONE particular row, i want to

  • show an option button (Update)
  • identify the contents of that row (primary key of table?)
  • On press of the Update button - move to the next screen with the values of that particular row from the DB

Can someone help me with this?

Current Code

DB table query

cursor = db.query(
                BANKTABLE_NAME,
                new String[]{BANKTABLE_ROW_ID, BANKTABLE_BANKNAME, BANKTABLE_BALAMT, BANKTABLE_CURRENCY},

Populating the Table from the above query

    private void updateTable()
{
    ArrayList<ArrayList<Object>> data = db.getAllRowsAsArrays();

    for (int position=0; position < data.size(); position++)
    {
        TableRow tableRow= new TableRow(this);

        ArrayList<Object> row = data.get(position);

        TextView bankNameN = new TextView(this);
        bankNameN.setText(row.get(1).toString());
        tableRow.addView(bankNameN);

        passCurrency = row.get(3).toString();

        currencyTable();

        TextView balINRA = new TextView(this);
        balINRA.setText(String.valueOf((Integer.parseInt(row.get(2).toString()))*rateForCalc));
        tableRow.addView(balINRA);


        dataTable.addView(tableRow);
    }
}
Ridcully
  • 23,362
  • 7
  • 71
  • 86
Jasma
  • 133
  • 3
  • 12

1 Answers1

0

for achieving it you should create custom adapter for list. Add gesture listener on row layout- Your should use this question for getting information about swap HERE

When user swipe on row while it onItemClickListner call in this listner you get row no of list so you get information from DB using this row no. Also implement onClicked listener in side getView method for Button(Update).

I hope its helpful to you.

Community
  • 1
  • 1
DynamicMind
  • 4,240
  • 1
  • 26
  • 43