假設我有內部TableLayout視圖,就像這樣:我如何找出表格佈局內的視圖的行/列
TableLayout tableLayout;
View view = (View)tableLayout.findViewById(R.id.control);
我怎樣才能找出TableLayout內的視圖的行/列?
假設我有內部TableLayout視圖,就像這樣:我如何找出表格佈局內的視圖的行/列
TableLayout tableLayout;
View view = (View)tableLayout.findViewById(R.id.control);
我怎樣才能找出TableLayout內的視圖的行/列?
在TableRow中的視圖應該有TableRow.LayoutParams作爲其LayoutParams。從那你可以得到layout_column。
該行似乎有點困難。我期望TableLayout.LayoutParams(從TableRow獲得)擁有這些信息,但似乎並不如此。你可以嘗試使用tableLayout.getIndexOfChild(rowView)。
TableLayout類中沒有這樣的getIndexOfChild(view),但是indexOfChild()!
在代碼中設計表格時,可以使用setTag()將其設置爲行號。稍後它可以通過tableRow.getTag()來檢索。在xml中,你可以使用android:tag =「2」。