下面列出了怎么用android.widget.TableRow的API类实例代码及写法,或者点击链接到github查看源代码。
ResultItemViewHolder(View v) {
super(v);
mActionName = (TextView) v.findViewById(R.id.text_case_result_step_title);
mActionParam = (TextView) v.findViewById(R.id.text_case_result_step_param);
mPrepareActions = (TextView) v.findViewById(R.id.text_case_result_step_prepare);
mStatus = (TextView) v.findViewById(R.id.text_case_result_step_status);
mParamRow = (TableRow) v.findViewById(R.id.row_case_result_step_param);
mPrepareRow = (TableRow) v.findViewById(R.id.row_case_result_step_prepare);
mNodeRow = (TableRow) v.findViewById(R.id.row_case_result_step_node);
mCaptureRow = (TableRow) v.findViewById(R.id.row_case_result_step_capture);
mTargetNode = mNodeRow.findViewById(R.id.text_case_result_step_target_node);
mFindNode = mNodeRow.findViewById(R.id.text_case_result_step_find_node);
mTargetCapture = (ImageView) mCaptureRow.findViewById(R.id.img_case_result_target);
mFindCapture = (ImageView) mCaptureRow.findViewById(R.id.img_case_result_find);
mTargetNode.setOnClickListener(this);
mFindNode.setOnClickListener(this);
mTargetCapture.setOnClickListener(this);
mFindCapture.setOnClickListener(this);
}
public void setAdapter(BaseAdapter adapter) {
if (adapter != null) {
if (adapter.getCount() < this.rowNum * this.colNum) {
throw new IllegalArgumentException("The view count of adapter is less than this gridview's items");
}
this.removeAllViews();
for (int y = 0; y < rowNum; ++y) {
TableRow row = new TableRow(context);
row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
for (int x = 0; x < colNum; ++x) {
View view = adapter.getView(y * colNum + x, this, row);
row.addView(view, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
}
this.addView(row);
}
}
this.adapter = adapter;
}
private void createTableHeader() {
TableRow tableRow = new TableRow(context);
tableRow.setLayoutParams(createTableLayoutParam());
for (int i = 0; i < columnCount; i++) {
TextView tv = new TextView(context);
if (i == 0) {
tv.setLayoutParams(createTableRowParam(sideCellWidth, cellHeight));
} else {
tv.setLayoutParams(createTableRowParam(cellHeight));
}
tv.setTextColor(getResources().getColor(R.color.colorHeaderText));
tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_HEADER_FONT_SIZE_DP);
tv.setText(headerTitle[i]);
tv.setGravity(Gravity.CENTER);
tableRow.addView(tv);
}
tableHeader.addView(tableRow);
}
private View createNetworkRow(NetworkInterfaceInformation interfaceInformation) {
final TableRow tempRow = new TableRow(this);
tempRow.addView(createTextView(interfaceInformation.getName()));
CharSequence statusText;
if (interfaceInformation.isHasCarrier()) {
statusText = getText(R.string.network_status_up);
} else {
statusText = getText(R.string.network_status_down);
}
tempRow.addView(createTextView(statusText.toString()));
if (interfaceInformation.getIpAdress() != null) {
tempRow.addView(createTextView(interfaceInformation.getIpAdress()));
} else {
tempRow.addView(createTextView(" - "));
}
if (interfaceInformation.getWlanInfo() != null) {
final WlanBean wlan = interfaceInformation.getWlanInfo();
tempRow.addView(createTextView(FormatHelper.formatPercentage(wlan.getSignalLevel())));
tempRow.addView(createTextView(FormatHelper.formatPercentage(wlan.getLinkQuality())));
} else {
tempRow.addView(createTextView(" - "));
tempRow.addView(createTextView(" - "));
}
return tempRow;
}
/**
* Add full access condition information about one sector to the layout
* table. (This method will trigger
* {@link #addBlockAC(byte[][], boolean)} and
* {@link #addSectorTrailerAC(byte[][])}
* @param acMatrix Matrix of access conditions bits (C1-C3) where the first
* dimension is the "C" parameter (C1-C3, Index 0-2) and the second
* dimension is the block number
* (Block0-Block2 + Sector Trailer, Index 0-3).
* @param sectorHeader The sector header to display (e.g. "Sector: 0").
* @param hasMoreThan4Blocks True for the last 8 sectors
* of a MIFARE Classic 4K tag.
* @see #addBlockAC(byte[][], boolean)
* @see #addSectorTrailerAC(byte[][])
*/
private void addSectorAC(byte[][] acMatrix, String sectorHeader,
boolean hasMoreThan4Blocks) {
// Add sector header.
TextView header = new TextView(this);
header.setText(Common.colorString(sectorHeader,
getResources().getColor(R.color.blue)),
BufferType.SPANNABLE);
TableRow tr = new TableRow(this);
tr.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
tr.addView(header);
mLayout.addView(tr, new LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
// Add Block 0-2.
addBlockAC(acMatrix, hasMoreThan4Blocks);
// Add Sector Trailer.
addSectorTrailerAC(acMatrix);
}
private void SetCustomButtons(View view){
TableRow customButtonLayout = view.findViewById(R.id.custom_button_layout);
if(customButtonLayout == null) return;
if(sharedPref.getBoolean(getString(R.string.preference_enable_custom_buttons), false)){
customButtonLayout.setVisibility(View.VISIBLE);
for(int resourceId: new Integer[]{R.id.custom_button_1, R.id.custom_button_2, R.id.custom_button_3, R.id.custom_button_4}){
IconButton iconButton = view.findViewById(resourceId);
if(resourceId == R.id.custom_button_1) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_one), getString(R.string.text_value_na)));
if(resourceId == R.id.custom_button_2) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_two), getString(R.string.text_value_na)));
if(resourceId == R.id.custom_button_3) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_three), getString(R.string.text_value_na)));
if(resourceId == R.id.custom_button_4) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_four), getString(R.string.text_value_na)));
iconButton.setOnLongClickListener(this);
iconButton.setOnClickListener(this);
}
}else{
customButtonLayout.setVisibility(View.GONE);
}
}
public static void setChildWidthForTableLayout(View view, int width) {
Object layoutParams = view.getLayoutParams();
if (layoutParams instanceof TableRow.LayoutParams) {
TableRow.LayoutParams tableLayoutParams = (TableRow.LayoutParams) layoutParams;
switch (width) {
case Component.LENGTH_PREFERRED:
tableLayoutParams.width = TableRow.LayoutParams.WRAP_CONTENT;
break;
case Component.LENGTH_FILL_PARENT:
tableLayoutParams.width = TableRow.LayoutParams.FILL_PARENT;
break;
default:
tableLayoutParams.width = calculatePixels(view, width);
break;
}
view.requestLayout();
} else {
Log.e("ViewUtil", "The view does not have table layout parameters");
}
}
protected void appendRow( String value ){
// create table row
TableLayout tb = (TableLayout)findViewById(R.id.control_table_layout);
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(tableLayout);
// get current time
long time = System.currentTimeMillis();
SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String cur_time = dayTime.format(new Date(time));
// set Text on TextView
TextView tv_left = new TextView(this);
tv_left.setText( cur_time );
tv_left.setLayoutParams( tableRowLayout );
tableRow.addView( tv_left );
TextView tv_right = new TextView(this);
tv_right.setText( value );
tv_right.setLayoutParams( tableRowLayout );
tableRow.addView( tv_right );
// set table rows on table
tb.addView(tableRow);
}
protected void showCellCdma(CellTowerCdma cellTower) {
TableRow row = (TableRow) mainActivity.getLayoutInflater().inflate(R.layout.ril_cdma_list_item, null);
TextView type = (TextView) row.findViewById(R.id.type);
TextView sid = (TextView) row.findViewById(R.id.sid);
TextView nid = (TextView) row.findViewById(R.id.nid);
TextView bsid = (TextView) row.findViewById(R.id.bsid);
TextView dbm = (TextView) row.findViewById(R.id.dbm);
type.setTextColor(rilCdmaCells.getContext().getResources().getColor(getColorFromGeneration(cellTower.getGeneration())));
type.setText(rilCdmaCells.getContext().getResources().getString(R.string.smallDot));
sid.setText(formatCellData(rilCdmaCells.getContext(), null, cellTower.getSid()));
nid.setText(formatCellData(rilCdmaCells.getContext(), null, cellTower.getNid()));
bsid.setText(formatCellData(rilCdmaCells.getContext(), null, cellTower.getBsid()));
dbm.setText(formatCellDbm(rilCdmaCells.getContext(), null, cellTower.getDbm()));
rilCdmaCells.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
public void updateOnView(List<ScaleMeasurement> scaleMeasurementList)
{
tableHeaderView.removeAllViews();
final int iconHeight = pxImageDp(20);
ArrayList<MeasurementView> visibleMeasurements = new ArrayList<>();
for (MeasurementView measurement : measurementViews) {
if (!measurement.isVisible() || measurement instanceof UserMeasurementView) {
continue;
}
ImageView headerIcon = new ImageView(tableView.getContext());
headerIcon.setImageDrawable(measurement.getIcon());
headerIcon.setColorFilter(ColorUtil.getTintColor(tableView.getContext()));
headerIcon.setLayoutParams(new TableRow.LayoutParams(0, iconHeight, 1));
headerIcon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
tableHeaderView.addView(headerIcon);
visibleMeasurements.add(measurement);
}
adapter.setMeasurements(visibleMeasurements, scaleMeasurementList);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);
this.recipe = ((RecipeActivity) getActivity()).mRecipe;
TableLayout table = (TableLayout) rootView.findViewById(R.id.ingredientsTable);
for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
TableRow row = (TableRow) inflater.inflate(R.layout.ingredients_row, null);
((TextView) row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
((TextView) row.findViewById(R.id.attrib_value)).setText(ingredient
.getDescription());
table.addView(row);
}
return rootView;
}
public Boolean handleOtherDetailsDropdown(Boolean is_otherdetail_dropdown, ImageButton icon, final TableRow other_details_text) {
if (is_otherdetail_dropdown) {
other_details_text.setVisibility(View.GONE);
icon.setImageResource(R.drawable.ic_arrow_drop_down_black_24dp);
return false;
} else {
other_details_text.setVisibility(View.VISIBLE);
icon.setImageResource(R.drawable.ic_arrow_drop_up_black_24dp);
//Adjusting the scrollview for smaller screens
scroll_view.post(new Runnable() {
@Override
public void run() {
scroll_view.scrollTo(0, other_details_text.getBottom());
}
});
return true;
}
}
/**
* Starts the clicked game. This uses the total index position of the clicked view to get the
* game.
*
* @param view The clicked view.
*/
private void startGame(View view) {
TableRow row = (TableRow) view.getParent();
TableLayout table = (TableLayout) row.getParent();
ArrayList<Integer> orderedList = lg.getOrderedGameList();
int index = indexes.get(table.indexOfChild(row) * menuColumns + row.indexOfChild(view));
index = orderedList.indexOf(index);
//avoid loading two games at once when pressing two buttons at once
if (prefs.getSavedCurrentGame() != DEFAULT_CURRENT_GAME) {
return;
}
prefs.saveCurrentGame(index);
Intent intent = new Intent(getApplicationContext(), GameManager.class);
intent.putExtra(GAME, index);
startActivityForResult(intent, 0);
}
/**
* Creates a View that is rendered in the dialog window.
*
* @param ctx Android application context.
* @return A View instance to render on the dialog.
*/
@Override
public final View createView(Context ctx) {
// TODO: Inflate this instead
// Ensure input boxes fill the entire width of the dialog.
TableRow.LayoutParams trParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT);
trParams.weight = 1.0F;
TableLayout layout = new TableLayout(ctx);
TableRow shareRow = new TableRow(ctx);
shareRow.setLayoutParams(trParams);
TableRow nickRow = new TableRow(ctx);
nickRow.setLayoutParams(trParams);
TextView textShare = new TextView(ctx);
textShare.setText(R.string.label_share_url);
TextView textNick = new TextView(ctx);
textNick.setText(R.string.label_nickname);
this.dialogTxtShare = new EditText(ctx);
this.dialogTxtShare.setInputType(InputType.TYPE_CLASS_TEXT);
this.dialogTxtShare.setLayoutParams(trParams);
this.dialogTxtShare.addTextChangedListener(new LinkIDMatchReplacementListener(this.dialogTxtShare));
this.dialogTxtNick = new EditText(ctx);
this.dialogTxtNick.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
this.dialogTxtNick.setLayoutParams(trParams);
shareRow.addView(textShare);
shareRow.addView(this.dialogTxtShare);
nickRow.addView(textNick);
nickRow.addView(this.dialogTxtNick);
layout.addView(shareRow);
layout.addView(nickRow);
return layout;
}
/**
* Creates a TableRow with two columns containing TextViews, and adds it to
* the main TableView.
*/
@SuppressWarnings("deprecation")
private void addKeyValueRow(String key, String value) {
TableLayout tl = (TableLayout)mLayout.findViewById(R.id.extraExifInfo);
/* Create the TableRow */
TableRow tr = new TableRow(mActivity);
/* Create the left column for the key */
TextView textViewKey = new TextView(mActivity);
textViewKey.setText(key);
TableRow.LayoutParams leftColParams = new TableRow.LayoutParams(
0, TableLayout.LayoutParams.WRAP_CONTENT, 1f);
textViewKey.setLayoutParams(leftColParams);
tr.addView(textViewKey);
/* Create the right column for the value */
TextView textViewValue = new TextView(mActivity);
textViewValue.setText(value);
textViewValue.setTextColor(
mActivity.getResources().getColor(R.color.flickr_pink));
textViewValue.setMaxLines(1);
textViewValue.setEllipsize(TextUtils.TruncateAt.END);
TableRow.LayoutParams lp = new TableRow.LayoutParams(
0, TableLayout.LayoutParams.WRAP_CONTENT, 1f);
/* left, top, right, bottom */
lp.setMargins(8, 0, 0, 0);
textViewValue.setLayoutParams(lp);
tr.addView(textViewValue);
/* Add the row to the table */
tl.addView(tr);
}
private void initThis(Context context, AttributeSet attrs) {
this.context = context;
if (this.getTag() != null) {
String atb = (String) this.getTag();
int ix = atb.indexOf(',');
if (ix > 0) {
rowNum = Integer.parseInt(atb.substring(0, ix));
colNum = Integer.parseInt(atb.substring(ix + 1, atb.length()));
}
}
if (rowNum <= 0)
rowNum = 3;
if (colNum <= 0)
colNum = 3;
if (this.isInEditMode()) {
this.removeAllViews();
for (int y = 0; y < rowNum; ++y) {
TableRow row = new TableRow(context);
row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1.0f));
for (int x = 0; x < colNum; ++x) {
View button = new Button(context);
row.addView(button, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
}
this.addView(row);
}
}
}
private TableRow createTableRow() {
TableRow row = new TableRow(getContext());
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
row.setLayoutParams(params);
return row;
}
private TableRow createTableRow() {
TableRow row = new TableRow(getContext());
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
row.setLayoutParams(params);
return row;
}
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();
}
private void addField (HtmlInput field) {
Log.d(Constants.TAG, "adding ["+field.getName() + "], type = [" + field.getType()+"]");
TextView labelView = new TextView(this);
labelView.setText(field.getName());
int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, (float) 8, getResources().getDisplayMetrics());
labelView.setTextSize (textSize);
EditText editView = new EditText(this);
editView.setInputType(field.getAndroidInputType());
editView.setText (field.getValue());
editView.setTag(field.getName());
editView.setFocusable (true);
edits.add(editView);
editView.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
onSaveClick(v);
}
return false;
}
});
TableRow row = new TableRow (this);
fieldsTable.addView (row, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,TableLayout.LayoutParams.WRAP_CONTENT));
TableRow.LayoutParams labelLayout = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 5, getResources().getDisplayMetrics());
labelLayout.setMargins(margin, margin, margin, margin);
row.addView(labelView, labelLayout);
TableRow.LayoutParams editLayout = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.WRAP_CONTENT);
row.addView(editView, editLayout);
}
/**
* Creates a color swatch.
*/
private ColorPickerSwatch createColorSwatch(int color, int selectedColor, int width,
int strokeColor) {
ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color,
color == selectedColor, width, strokeColor, mOnColorSelectedListener);
TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
view.setLayoutParams(params);
return view;
}
/**
* Appends a swatch to the end of the row for even-numbered rows (starting with row 0), to the beginning of a row for odd-numbered rows.
*/
private void addSwatchToRow(TableRow row, View swatch, int rowNumber) {
if (rowNumber % 2 == 0) {
row.addView(swatch);
} else {
row.addView(swatch, 0);
}
}
private void setVisibility(TableRow row) {
String currentCategory = categoryField.getText().toString();
String rowCategory = ((TextView)row.getVirtualChildAt(1)).getText().toString();
boolean active = ((CheckBox)row.getVirtualChildAt(0)).isChecked();
boolean visible = (currentCategory.equals(ALL_CATEGORIES)) ||
(currentCategory.equals(ALL_ACTIVE) && active) ||
(rowCategory.equals(NEW_ITEM)) ||
(rowCategory.equals(currentCategory));
if (visible)
row.setVisibility(View.VISIBLE);
else
row.setVisibility(View.GONE);
}
/**
* Appends a swatch to the end of the row for even-numbered rows (starting with row 0),
* to the beginning of a row for odd-numbered rows
*/
private static void addSwatchToRow(TableRow row, View swatch, int rowNumber) {
if (rowNumber % 2 == 0) {
row.addView(swatch);
} else {
row.addView(swatch, 0);
}
}
private void updateView() {
int count = configTable.getChildCount() - 2;
for (int i = 0; i < count; i++) {
TableRow row = ((TableRow) configTable.getChildAt(i + 1));
setVisibility(row);
}
}
private void showEditDialog(TableRow row) {
editedRow = row;
View[] currentContent = getContentCells(editedRow);
((CheckBox)editDialog.findViewById(R.id.activeChk)).setChecked(((CheckBox)currentContent[0]).isChecked());
((TextView)editDialog.findViewById(R.id.filterCategory)).setText(((TextView)currentContent[1]).getText().toString());
((TextView)editDialog.findViewById(R.id.filterName)).setText(((TextView)currentContent[2]).getText().toString());
((TextView)editDialog.findViewById(R.id.filterUrl)).setText(((TextView)currentContent[3]).getText().toString());
editDialog.show();
WindowManager.LayoutParams lp = editDialog.getWindow().getAttributes();
lp.width = (int)(configTable.getContext().getResources().getDisplayMetrics().widthPixels*1.00);;
editDialog.getWindow().setAttributes(lp);
}
private static void setTextViewParams(TextView textView, int color, String text, boolean typeFaceLight, float textSize, int gravity) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, textSize);
textView.setGravity(gravity);
textView.setTextColor(color);
textView.setText(text);
if (typeFaceLight) {
textView.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
} else {
textView.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
}
TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
params.bottomMargin = 4;
// params.setMarginStart(16);
textView.setLayoutParams(params);
}
protected void tabletTilePortrait() {
int sizeNow, index = 0, halfSizeOnHold = 0;
boolean cell_open = false;
Iterator<bind> loop = list_configuration.iterator();
TableRow temp_row = newTempHolder();
while (loop.hasNext()) {
bind dlp = loop.next();
sizeNow = dlp.size;
if (sizeNow == bind.FULL) {
if (cell_open) {
//close half
temp_row = newTempHolderBy2();
ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, calculateRowHeightBy2()));
cell_open = false;
halfSizeOnHold = 0;
}
ll.addView(newRelativeLayout(dlp, sizeNow));
} else if (sizeNow == bind.HALF) {
if (!cell_open) {
temp_row = newTempHolder();
cell_open = true;
}
halfSizeOnHold++;
//adding view to layout
temp_row.addView(newRelativeLayout(dlp, sizeNow));
}
if (index == list_configuration.size() - 1 && cell_open || cell_open && halfSizeOnHold >= 3) {
ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, row_height));
cell_open = false;
halfSizeOnHold = 0;
}
index++;
}
}
/**
* Appends a swatch to the end of the row for even-numbered rows (starting with row 0),
* to the beginning of a row for odd-numbered rows.
*/
private static void addSwatchToRow(TableRow row, View swatch, int rowNumber,
boolean backwardsOrder) {
if (backwardsOrder) {
if (rowNumber % 2 == 0) {
row.addView(swatch);
} else {
row.addView(swatch, 0);
}
} else {
row.addView(swatch);
}
}
/**
* Computes currently selected radicals.
*/
private String getRadicals() {
final StringBuilder sb = new StringBuilder();
final TableLayout v = (TableLayout) findViewById(R.id.kanjisearchRadicals);
for (int i = 0; i < v.getChildCount(); i++) {
final TableRow tr = (TableRow) v.getChildAt(i);
for (int j = 0; j < tr.getChildCount(); j++) {
final PushButtonListener pbl = (PushButtonListener) tr.getChildAt(j).getTag();
if (pbl != null && pbl.isPushed()) {
sb.append(pbl.radical);
}
}
}
return sb.toString();
}