Java android tablelayout单击行与滚动

Java android tablelayout单击行与滚动,java,android,scroll,tablelayout,Java,Android,Scroll,Tablelayout,我有一个tablelayout,我需要在其中选择一行来处理它。问题是,当我滚动时,它会选择一个新行。 当我只想滚动时,我希望它是一种不选择行的方式 我选择行的方法是: ... TableRow tR = new TableRow(this); final TableLayout tabela = (TableLayout)findViewById(R.id.tableLayout1); ... tR.setOnTouchListener(new OnTouchListener() { publ

我有一个tablelayout,我需要在其中选择一行来处理它。问题是,当我滚动时,它会选择一个新行。 当我只想滚动时,我希望它是一种不选择行的方式

我选择行的方法是:

...
TableRow tR = new TableRow(this);
 final TableLayout tabela = (TableLayout)findViewById(R.id.tableLayout1);
...
tR.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent arg1) {
    tabela.getFocusedChild().setBackgroundResource(R.drawable.gray1);//remove the old selected row
    arg0.requestFocus(); //add new one
    arg0.setBackgroundColor(Color.parseColor("#FFFF00")); //add new one
    return false;
}});
我认为这与“MotionEvent arg1”有关,但我真的不知道该怎么办。
提前感谢您的帮助

我已经找到了解决这个问题的方法。 我只需要补充一下

if(arg1.getAction() == MotionEvent.ACTION_UP){
在输入代码之前

请尝试以下操作