本文整理匯總了Java中android.widget.TableRow.getChildCount方法的典型用法代碼示例。如果您正苦於以下問題:Java TableRow.getChildCount方法的具體用法?Java TableRow.getChildCount怎麽用?Java TableRow.getChildCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TableRow
的用法示例。
在下文中一共展示了TableRow.getChildCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initializeBoard
import android.widget.TableRow; //導入方法依賴的package包/類
protected void initializeBoard() {
size = 3;
board = new int[size][size];
mainBoard = findViewById(R.id.mainBoard);
tv_turn = findViewById(R.id.turn);
if (myTurn) {
tv_turn.setText(String.format(getString(R.string.your_turn),
String.valueOf(myTurnChar)));
} else {
tv_turn.setText(String.format(getString(R.string.their_turn),
rival.getNick(), String.valueOf(flipChar(myTurnChar))));
}
resetBoard(null);
for (int i = 0; i < mainBoard.getChildCount(); i++) {
TableRow row = (TableRow) mainBoard.getChildAt(i);
for (int j = 0; j < row.getChildCount(); j++) {
TextView tv = (TextView) row.getChildAt(j);
tv.setOnClickListener(MoveListener(i, j, tv));
tv.setTextColor(ContextCompat.getColor(getBaseContext(), R.color.black));
}
}
}
示例2: updateLayoutHolder
import android.widget.TableRow; //導入方法依賴的package包/類
public void updateLayoutHolder(View vToBeAdded, boolean bRemoveAllFirst) {
if (bRemoveAllFirst) {
mlLayoutholderInputPadCfg.removeAllViews();
}
mlLayoutholderInputPadCfg.addView(vToBeAdded);
vToBeAdded.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
if (vToBeAdded instanceof TableLayout) {
int nNumofRows = ((TableLayout)vToBeAdded).getChildCount();
for (int idx = 0; idx < nNumofRows; idx ++) {
TableRow tr = (TableRow)((TableLayout)vToBeAdded).getChildAt(idx);
tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
int nNumofBtns = tr.getChildCount();
for (int idx1 = 0; idx1 < nNumofBtns; idx1 ++) {
View vBtn = tr.getChildAt(idx1);
// height has been set before.
vBtn.setLayoutParams(new TableRow.LayoutParams(0, vBtn.getLayoutParams().height, 1));
}
}
}
}
示例3: altTableRow
import android.widget.TableRow; //導入方法依賴的package包/類
public void altTableRow(int alt_row) {
int childViewCount = tablelayout.getChildCount();
for (int i = 0; i < childViewCount; i++) {
TableRow row = (TableRow) tablelayout.getChildAt(i);
for (int j = 0; j < row.getChildCount(); j++) {
TextView tv = (TextView) row.getChildAt(j);
if (i % alt_row != 0) {
tv.setBackground(getResources().getDrawable(
R.drawable.alt_row_color));
} else {
tv.setBackground(getResources().getDrawable(
R.drawable.row_color));
}
}
}
}
示例4: altTableRow
import android.widget.TableRow; //導入方法依賴的package包/類
/**
* alternate colors for description rows
*
* @param alt_row
*/
public void altTableRow(int alt_row) {
int childViewCount = tablelayout.getChildCount();
for (int i = 0; i < childViewCount; i++) {
TableRow row = (TableRow) tablelayout.getChildAt(i);
for (int j = 0; j < row.getChildCount(); j++) {
TextView tv = (TextView) row.getChildAt(j);
if (i % alt_row != 0) {
tv.setBackground(getResources().getDrawable(
R.drawable.alt_row_color));
} else {
tv.setBackground(getResources().getDrawable(
R.drawable.row_color));
}
}
}
}
示例5: columnAtPoint
import android.widget.TableRow; //導入方法依賴的package包/類
public int columnAtPoint(Point point) {
if(tableView == null){
return -1;
}
int[] winLoc = new int[2];
int[] viewLoc = new int[2];
tableView.getLocationInWindow(winLoc);
TableRow tableRow = (TableRow)tableView.getChildAt(0);
int columnNum = tableRow.getChildCount();
for (int i = 1; i < columnNum; i++) {
tableRow.getVirtualChildAt(i).getLocationInWindow(viewLoc);
int shiftX = viewLoc[0] - winLoc[0];
if(i == 1){
if(point.x < shiftX){
return -1;
}
}
if(point.x < shiftX){
return i - 1;
}
}
return columnNum - 1;
}
示例6: altTableRow
import android.widget.TableRow; //導入方法依賴的package包/類
/**
* alternate between 2 colors for the description item table
*
* @param alt_row
*/
public void altTableRow(int alt_row) {
int childViewCount = tablelayout.getChildCount();
for (int i = 0; i < childViewCount; i++) {
TableRow row = (TableRow) tablelayout.getChildAt(i);
for (int j = 0; j < row.getChildCount(); j++) {
TextView tv = (TextView) row.getChildAt(j);
if (i % alt_row != 0) {
tv.setBackground(getResources().getDrawable(
R.drawable.alt_row_color));
} else {
tv.setBackground(getResources().getDrawable(
R.drawable.row_color));
}
}
}
}
示例7: altTableRow
import android.widget.TableRow; //導入方法依賴的package包/類
/**
* alternate colors for description rows
*
* @param alt_row
*/
public void altTableRow(int alt_row, TableLayout tablelayout) {
int childViewCount = tablelayout.getChildCount();
for (int i = 0; i < childViewCount; i++) {
TableRow row = (TableRow) tablelayout.getChildAt(i);
for (int j = 0; j < row.getChildCount(); j++) {
TextView tv = (TextView) row.getChildAt(j);
if (i % alt_row != 0) {
tv.setBackground(getResources().getDrawable(
R.drawable.alt_row_color));
} else {
tv.setBackground(getResources().getDrawable(
R.drawable.row_color));
}
}
}
}
示例8: disableInputs
import android.widget.TableRow; //導入方法依賴的package包/類
protected void disableInputs() {
// disable play inputs
for (int i = 0; i < mainBoard.getChildCount(); i++) {
TableRow row = (TableRow) mainBoard.getChildAt(i);
for (int j = 0; j < row.getChildCount(); j++) {
TextView tv = (TextView) row.getChildAt(j);
tv.setOnClickListener(null);
tv.setTextColor(ContextCompat.getColor(getBaseContext(), R.color.gray));
}
}
}
示例9: setClearingLayoutSizes
import android.widget.TableRow; //導入方法依賴的package包/類
public void setClearingLayoutSizes(View rootView, Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
dpHeight -= addClearingButton.getHeight();
dpHeight /= 9;
dpWidth /= 7;
int finalValue = (int) Math.min(dpHeight, dpWidth);
TableLayout table = rootView.findViewById(R.id.clearingGrid);
final int childcount = table.getChildCount();
for (int i = 0; i < childcount; i++) {
TableRow row = (TableRow) table.getChildAt(i);
final int cellCount = row.getChildCount();
for (int j = 0; j < cellCount; j++) {
TextView cell = (TextView) row.getChildAt(j);
cell.setHeight(finalValue);
cell.setWidth(finalValue);
}
}
}
示例10: getCell
import android.widget.TableRow; //導入方法依賴的package包/類
private CustomEditText getCell(int row, int col)
{
if (row < getChildCount())
{
final TableRow tr = (TableRow) getChildAt(row);
if (tr != null && col < tr.getChildCount())
{
return (CustomEditText) tr.getChildAt(col);
}
}
return null;
}
示例11: setChildrenOnClickListener
import android.widget.TableRow; //導入方法依賴的package包/類
/**
*
* @param tr -
*/
private void setChildrenOnClickListener( TableRow tr ){
final int c = tr.getChildCount();
for ( int i = 0; i < c; i++ ){
View v = tr.getChildAt(i);
if ( v instanceof RadioButton ) v.setOnClickListener(this);
}
}
示例12: arrangeButtons
import android.widget.TableRow; //導入方法依賴的package包/類
private void arrangeButtons() {
// iterates over each button and puts it in the right place
for (int i = 0, len = mRadioButtons.size(); i < len; i++) {
RadioButton radioButtonToPlace = mRadioButtons.get(i);
int rowToInsert = (mMaxInRow != 0) ? i / mMaxInRow : 0;
int columnToInsert = (mMaxInRow != 0) ? i % mMaxInRow : i;
// gets the row to insert. if there is no row create one
TableRow tableRowToInsert = (mTableLayout.getChildCount() <= rowToInsert)
? addTableRow() : (TableRow) mTableLayout.getChildAt(rowToInsert);
int tableRowChildCount = tableRowToInsert.getChildCount();
// if there is already a button in the position
if (tableRowChildCount > columnToInsert) {
RadioButton currentButton = (RadioButton) tableRowToInsert.getChildAt(columnToInsert);
// insert the button just if the current button is different
if (currentButton != radioButtonToPlace) {
// removes the current button
removeButtonFromParent(currentButton, tableRowToInsert);
// removes the button to place from its current position
removeButtonFromParent(radioButtonToPlace, (ViewGroup) radioButtonToPlace.getParent());
// adds the button to the right place
tableRowToInsert.addView(radioButtonToPlace, columnToInsert);
}
// if there isn't already a button in the position
} else {
// removes the button to place from its current position
removeButtonFromParent(radioButtonToPlace, (ViewGroup) radioButtonToPlace.getParent());
// adds the button to the right place
tableRowToInsert.addView(radioButtonToPlace, columnToInsert);
}
}
removeRedundancies();
}
示例13: resize
import android.widget.TableRow; //導入方法依賴的package包/類
public void resize(int rows, int cols, int cellLayoutId)
{
if (rowsNumber == rows && colsNumber == cols)
{
return;
}
rowsNumber = rows;
colsNumber = cols;
removeAllViews();
fields.clear();
final TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);
final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
for (int row = 0; row < rowsNumber; row++)
{
final TableRow tableRow = new TableRow(getContext());
tableRow.setLayoutParams(tableParams); // TableLayout is the parent view
addView(tableRow);
for (int col = 0; col < colsNumber; col++)
{
inflater.inflate(cellLayoutId, tableRow);
}
if (tableRow.getChildCount() > 0)
{
tableRow.setBaselineAligned(true);
tableRow.setBaselineAlignedChildIndex(0);
}
for (int col = 0; col < tableRow.getChildCount(); col++)
{
final CustomEditText c = (CustomEditText) tableRow.getChildAt(col);
if (c != null)
{
c.setId(IdGenerator.generateId());
c.setTag(new ElementTag(row, col, fields.size()));
fields.add(c);
}
}
}
setPadding(0, 0, 0, 0);
setBaselineAligned(true);
setBaselineAlignedChildIndex(rowsNumber > 1 ? rowsNumber / 2 : 0);
}
示例14: checkInput
import android.widget.TableRow; //導入方法依賴的package包/類
private ArrayList<String> checkInput(View table) {
if (!(table instanceof TableLayout)) return null;
ArrayList<String> result = new ArrayList<>();
TableLayout tableLayout = (TableLayout) table;
final int childCount = tableLayout.getChildCount();
for (int i = 0; i < childCount; i++) {
View tableChild = tableLayout.getChildAt(i);
if (tableChild instanceof TableRow) {
TableRow tableRow = (TableRow) tableChild;
final int count = tableRow.getChildCount();
for (int j = 0; j < count; j++) {
View childView = tableRow.getChildAt(j);
if (!(childView instanceof EditText)) continue;
EditText editText = (EditText) childView;
String type = editText.getHint().toString();
String method = (String) editText.getTag();
String input = editText.getText().toString().trim();
if (TextUtils.isEmpty(input)) continue;
String[] methods = input.split("\n");
for (String m : methods) {
String methodType = "";
String[] args = m.split(",");
if (type.equals(PARENT_TYPE)) {
if (args.length == 1) {
methodType = ITEM_OPERATE_TYPE;
} else if (args.length == 2) {
methodType = ITEM_RANGE_OPERATE_TYPE;
}
} else if (type.equals(CHILD_TYPE)) {
if (args.length == 2) {
methodType = ITEM_OPERATE_TYPE;
} else if (args.length == 3) {
methodType = ITEM_RANGE_OPERATE_TYPE;
}
} else if (type.equals(MOVE_PARENT_TYPE)) {
if (args.length == 2) {
methodType = ITEM_OPERATE_TYPE;
}
} else if (type.equals(MOVE_CHILD_TYPE)) {
if (args.length == 4) {
methodType = ITEM_OPERATE_TYPE;
}
}
String methodName = String.format(method, methodType);
String ma = String.format(getString(R.string.methodAndArgs), methodName, m);
result.add(ma);
}
}
}
}
Logger.e(TAG, "requestList=" + result.toString());
return result;
}
示例15: removeRedundancies
import android.widget.TableRow; //導入方法依賴的package包/類
private void removeRedundancies() {
// the number of rows to fit the buttons
int rows;
if (mRadioButtons.size() == 0)
rows = 0;
else if (mMaxInRow == 0)
rows = 1;
else
rows = (mRadioButtons.size() - 1) / mMaxInRow + 1;
int tableChildCount = mTableLayout.getChildCount();
// if there are redundant rows remove them
if (tableChildCount > rows)
mTableLayout.removeViews(rows, tableChildCount - rows);
tableChildCount = mTableLayout.getChildCount();
int maxInRow = (mMaxInRow != 0) ? mMaxInRow : mRadioButtons.size();
// iterates over the rows
for (int i = 0; i < tableChildCount; i++) {
TableRow tableRow = (TableRow) mTableLayout.getChildAt(i);
int tableRowChildCount = tableRow.getChildCount();
int startIndexToRemove;
int count;
// if it is the last row removes all redundancies after the last button in the list
if (i == tableChildCount - 1) {
startIndexToRemove = (mRadioButtons.size() - 1) % maxInRow + 1;
count = tableRowChildCount - startIndexToRemove;
// if it is not the last row removes all the buttons after maxInRow position
} else {
startIndexToRemove = maxInRow;
count = tableRowChildCount - maxInRow;
}
if (count > 0)
tableRow.removeViews(startIndexToRemove, count);
}
}