Events in tableview on Android

You must Login before you can answer or comment on any questions.

Goal: in relation to kind of event incrementing or decrementing of a value.

After click I increment a cell.

tv.addEventListener('click', function(e) {
    var total = 0;
    e.row.count++;
    e.row.countlabel.setText((e.row.count > 0)  ? '' + e.row.count : '');
    var prize = e.row.prizelabel.text;
    e.row.prize = e.row.count * parseFloat(prize);
    for (var i = 0; i < menue.length; i++) {
        total += rows[i].prize;
    }
    totalprize.text = total.toFixed(2) + ' EUR   ';
});
In tableview s list of products with prizes.

Now I want to decrement the count after other event.

  • longpress only gives me the standard properties of source row, no index, no special custom properties
  • swipe will mot fired.

Any ideas?

Rainer

— asked 12 months ago by Rainer Schleevoigt
2 Comments
  • Does touchstart and touchend give you the event data that you need? If so, you could save the current time to a variable on touchstart and compare the time at touchend, and if the time that has elapsed is greater than a time that you determine, you have your longpress. If it's shorter than the amount of time you specify, you have your click event.

    Seems like a lot of work maybe, but it's just a quick idea.

    — commented 12 months ago by Darren Adams

  • Hi Rainer,

    I think You need to use

    e.rowData.count++
    instead of
    e.row.count++;

    — commented 12 months ago by Nitin Chavda

Your Answer

Think you can help? Login to answer this question!