listener - Android - basic gesture detection in TableLayout -
i new android development, please excuse naivety of post. have table layout in dynamically adding text view each cell. wish add swipe detection on cells , perform action on basis of cell swiped. tried adding onswipetouchlistener on each of cell.
textview txtviewcell = new textview(getactivity()); tablerow.layoutparams paramsexample = new tablerow.layoutparams(60, 60); txtviewcell.setbackgroundcolor(0xfffaf8ef); txtviewcell.setgravity(gravity.center); paramsexample.setmargins(5, 5, 5, 5); txtviewcell.setlayoutparams(paramsexample); final int currrow = i; final int currcol = j; txtviewcell.setontouchlistener(new onswipetouchlistener( getactivity()) { public void onswipetop() { handleswipe(currrow, currcol); } public void onswiperight() { handleswipe(currrow, currcol); } public void onswipeleft() { handleswipe(currrow, currcol); } public void onswipebottom() { handleswipe(currrow, currcol); } public boolean ontouch(view v, motionevent event) { return gesturedetector.ontouchevent(event); } }); allcells[i][j] = txtviewcell;
now when swipe control in onswipe function, not correct row number , col number. there specific way attach swipe event on textview , row number , col number of cell?
i guess every textview has different id, try getting id , making control flow it.
Comments
Post a Comment