use of android.widget.TableRow in project Rashr by DsLNeXuS.
the class CardUI method refresh.
//suppress this error message to be able to use spaces in higher api levels
@SuppressLint("NewApi")
public void refresh() {
if (mAdapter == null) {
mAdapter = new StackAdapter(mContext, mStacks, mSwipeable);
if (mListView != null) {
mListView.setAdapter(mAdapter);
} else if (mTableLayout != null) {
TableRow tr = null;
for (int i = 0; i < mAdapter.getCount(); i += mColumnNumber) {
//add a new table row with the current context
tr = new TableRow(mTableLayout.getContext());
tr.setOrientation(TableRow.HORIZONTAL);
tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
//add as many cards as the number of columns indicates per row
for (int j = 0; j < mColumnNumber; j++) {
if (i + j < mAdapter.getCount()) {
View card = mAdapter.getView(i + j, null, tr);
if (card.getLayoutParams() != null) {
card.setLayoutParams(new TableRow.LayoutParams(card.getLayoutParams().width, card.getLayoutParams().height, 1f));
} else {
card.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f));
}
tr.addView(card);
}
}
mTableLayout.addView(tr);
}
if (tr != null) {
//fill the empty space with spacers
for (int j = mAdapter.getCount() % mColumnNumber; j > 0; j--) {
View space = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
space = new Space(tr.getContext());
} else {
space = new View(tr.getContext());
}
space.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f));
tr.addView(space);
}
}
}
} else {
// in case swipeable changed;
mAdapter.setSwipeable(mSwipeable);
mAdapter.setItems(mStacks);
}
}
use of android.widget.TableRow in project android_frameworks_base by DirtyUnicorns.
the class AddColumnTest method testWidths.
@MediumTest
public void testWidths() throws Exception {
sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);
getInstrumentation().waitForIdleSync();
TableRow row1 = (TableRow) mTable.getChildAt(0);
TableRow row2 = (TableRow) mTable.getChildAt(1);
assertTrue(row1.getChildCount() < row2.getChildCount());
for (int i = 0; i < row1.getChildCount(); i++) {
assertEquals(row2.getChildAt(i).getWidth(), row1.getChildAt(i).getWidth());
}
}
use of android.widget.TableRow in project UltimateAndroid by cymcsg.
the class StretchViewActivity method showTable.
public void showTable() {
TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.CENTER;
layoutParams.leftMargin = 30;
layoutParams.bottomMargin = 10;
layoutParams.topMargin = 10;
for (int i = 0; i < 40; i++) {
TableRow tableRow = new TableRow(this);
TextView textView = new TextView(this);
textView.setText("Test stretch scroll view " + i);
textView.setTextSize(20);
textView.setPadding(15, 15, 15, 15);
tableRow.addView(textView, layoutParams);
if (i % 2 != 0) {
tableRow.setBackgroundColor(Color.LTGRAY);
} else {
tableRow.setBackgroundColor(Color.WHITE);
}
final int n = i;
tableRow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
}
});
mMainLayout.addView(tableRow);
}
}
use of android.widget.TableRow in project pictureapp by EyeSeeTea.
the class ImageOptionSingleQuestionView method setOptions.
@Override
public void setOptions(List<Option> options) {
TableRow tableRow = null;
for (int i = 0; i < options.size(); i++) {
Option option = options.get(i);
if (isNewRow(i)) {
tableRow = new TableRow(getContext());
tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT, 1));
mImageOptionsContainer.addView(tableRow);
}
ImageOptionView imageOptionView = createOptionView(option);
tableRow.addView(imageOptionView);
mImageOptionViews.add(imageOptionView);
}
}
use of android.widget.TableRow in project android_frameworks_base by AOSPA.
the class AddColumn method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.add_column_in_table);
final Button addRowButton = (Button) findViewById(R.id.add_row_button);
addRowButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final TableLayout table = (TableLayout) findViewById(R.id.table);
final TableRow newRow = new TableRow(AddColumn.this);
for (int i = 0; i < 4; i++) {
final TextView view = new TextView(AddColumn.this);
view.setText("Column " + (i + 1));
view.setPadding(3, 3, 3, 3);
newRow.addView(view, new TableRow.LayoutParams());
}
table.addView(newRow, new TableLayout.LayoutParams());
newRow.requestLayout();
}
});
}
Aggregations