for(int i=0;i<3;i++) { TableRow row = (TableRow)tblLayout.getChildAt(i); for(int j=0;j<3;j++){ Button button = (Button)row.getChildAt(j); // get child index on particular row String buttonText = button.getText().toString(); Log.i("Button index: "+(i+j), buttonText); } }
TableLayout tblLayout = (TableLayout)findViewById(R.id.tableLayout); TableRow row = (TableRow)tblLayout.getChildAt(0); // Here get row id depending on number of row Button button = (Button)row.getChildAt(XXX); // get child index on particular row String buttonText = button.getText().toString();
table.post(new Runnable() { @Override public void run() { TableRow tableRow = (TableRow)table.getChildAt(0); for(int i = 0; i < headerRow.getChildCount(); i++){ headerRow.getChildAt(i).setLayoutParams(new TableRow.LayoutParams(tableRow.getChildAt(i).getMeasuredWidth(), tableRow.getChildAt(i).getMeasuredHeight())); } } });
//... tr.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { TableRow t = (TableRow) view; TextView firstTextView = (TextView) t.getChildAt(0); TextView secondTextView = (TextView) t.getChildAt(1); String firstText = firstTextView.getText().toString(); String secondText = secondTextView.getText().toString(); } }); //...
public void onClick(View v){ TableRow row= (TableRow) findViewById(v.getId()); imageContainer=(<imageContainertype>) row.getChildAt(1); ImageView imageB =(ImageView) imageContainer.getChildAt(1); imageContainer.removeView(imageB); }
tv.setOnClickListener(new OnClickListener() { public void onClick(View voew) { TableRow t = (TableRow) voew; //Your Layout TextView firstTextView = (TextView) t.getChildAt(0); String firstText = firstTextView.getText().toString(); } });
TableLayout tbL = (TableLayout) findViewById(R.id.tbL); TableRow row1=(TableRow)tbL.getChildAt(0); SeekBar sb1=(SeekBar) row1.getChildAt(0); TextView txt1_1=(TextView) row1.getChildAt(1); TextView txt1_2=(TextView) row1.getChildAt(2); ..etc
tableRow.setClickable(true); //allows you to select a specific row tableRow.setOnClickListener(new OnClickListener() { public void onClick(View view) { TableRow tablerow = (TableRow) view; TextView sample = (TextView) tablerow.getChildAt(1); String result=sample.getText().toString(); Toast toast = Toast.makeText(myActivity, result, Toast.LENGTH_LONG); toast.show(); } });
//This will iterate through your table layout and get the total amount of cells. for(int i = 0; i < table.getChildCount(); i++) { //Remember that .getChildAt() method returns a View, so you would have to cast a specific control. TableRow row = (TableRow) table.getChildAt(i); //This will iterate through the table row. for(int j = 0; j < row.getChildCount(); j++) { Button btn = (Button) row.getChildAt(j); //Do what you need to do. } }
private void setChildrenOnClickListener(TableRow tr) { final int c = tr.getChildCount(); for (int i=0; i < c; i++) { final View v = tr.getChildAt(i); if (v instanceof RadioButton) { v.setOnClickListener(this); if (((RadioButton) v).isChecked()) activeRadioButton = (RadioButton) v; } } }
protected void initCheckBox(final int i, TableRow checkBoxes, Set<Integer> nbCounts) { final CheckBox checkBox = (CheckBox) checkBoxes.getChildAt(i); checkBox.setChecked(rule != null && nbCounts.contains(i)); setOnClickListener(checkBox); }
void setCheckboxStates() { Set<Integer> creationNbCounts = fragment.rule.getCreationNbCounts(); Set<Integer> survivalNbCounts = fragment.rule.getSurvivalNbCounts(); for (int i = 0; i < 9; i++) { CheckBox creation = (CheckBox) fragment.creationCheckBoxes.getChildAt(i); CheckBox survival = (CheckBox) fragment.survivalCheckBoxes.getChildAt(i); creation.setChecked(creationNbCounts.contains(i)); survival.setChecked(survivalNbCounts.contains(i)); } }
String myText; ((TextView) findViewById(R.id.tv)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TableRow tablerow = (TableRow)v.getParent(); TextView items = (TextView) tablerow.getChildAt(2); myText = items.getText().toString(); } });
TableRow tableRow = (TableRow)findViewById(R.id.tableRow1); int childCount = tableRow.getChildCount(); for (int i = 0; i < childCount; i++){ ImageView backgroundImg = (ImageView) tableRow.getChildAt(i); backgroundImg.setBackgroundColor(Color.rgb(255, 255, 255)); }
for (int i = 1000 + miTlCnt; i > 1000; i--) { TableLayout tl = (TableLayout)findViewById(i); if (tl != null) { for (int j = 0; j < tl.getChildCount(); j++) { TableRow row = (TableRow)tl.getChildAt(j); CheckBox chkCompleted = (CheckBox)row.getChildAt(1); } } }
TableLayout layout = (TableLayout) findViewById(R.id.IdTable); for (int i = 0; i < layout.getChildCount(); i++) { View child = layout.getChildAt(i); if (child instanceof TableRow) { TableRow row = (TableRow) child; for (int x = 0; x < row.getChildCount(); x++) { View view = row.getChildAt(x); view.setEnabled(false); } } }
TableLayout layout = (TableLayout) findViewById(R.id.Table_ID); for (int i = 0; i < layout.getChildCount(); i++) { View child = layout.getChildAt(i); if (child instanceof TableRow) { TableRow row = (TableRow) child; for (int x = 0; x < row.getChildCount(); x++) { View view = row.getChildAt(x);//Here you get Your Button View } } }
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; }
TableLayout table = (TableLayout)findViewById(R.id.scrollable_part); int sourceColumnIndex = 0; int targetColumnIndex = 1; for (int i = 0; i < table.getChildCount(); i++) { TableRow tr = (TableRow)table.getChildAt(i); View v = tr.getChildAt(sourceColumnIndex); tr.removeViewAt(sourceColumnIndex); tr.addView(v, targetColumnIndex); }
TableRow tableRow = lv.getItemAtPosition(1); for (int i = 0; i < tableRow.getChildCount(); i++) { View child = tableRow.getChildAt(i); if ( child instanceof TextView ) { TextView textView = (TextView) child; textView.DO_SOMETHIG__WITH_TEXT_VIEV(); textView.requestLayout(); } } tableRow.requestLayout();