是否可以像数独游戏那样做一张桌子,并将划分孔的线条点击?如果不是,我应该使用什么视图来制作具有可点击线条的网格?
谢谢!
答案 0 :(得分:2)
试试这个:
// create a new TableRow
TableRow row = new TableRow(this);
row.setClickable(true); //allows you to select a specific row
row.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
v.setBackgroundColor(Color.GRAY);
System.out.println("Row clicked: " + v.getId());
//get the data you need
TableRow tablerow = (TableRow)v.getParent();
TextView sample = (TextView) tablerow.getChildAt(2);
String result=sample.getText().toString();
}
});