Search in sources :

Example 46 with TableRow

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);
    }
}
Also used : StackAdapter(com.fima.cardsui.StackAdapter) Space(android.widget.Space) TableRow(android.widget.TableRow) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint)

Example 47 with TableRow

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());
    }
}
Also used : TableRow(android.widget.TableRow) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 48 with TableRow

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);
    }
}
Also used : TableRow(android.widget.TableRow) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 49 with 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);
    }
}
Also used : TableRow(android.widget.TableRow) Option(org.eyeseetea.malariacare.data.database.model.Option) TableLayout(android.widget.TableLayout) ImageOptionView(org.eyeseetea.malariacare.views.option.ImageOptionView)

Example 50 with TableRow

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();
        }
    });
}
Also used : Button(android.widget.Button) TableRow(android.widget.TableRow) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) TableLayout(android.widget.TableLayout)

Aggregations

TableRow (android.widget.TableRow)77 TextView (android.widget.TextView)53 TableLayout (android.widget.TableLayout)37 View (android.view.View)30 Button (android.widget.Button)11 ImageView (android.widget.ImageView)10 SuppressLint (android.annotation.SuppressLint)7 ScrollView (android.widget.ScrollView)7 CPU (brunonova.drmips.simulator.CPU)7 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 CheckBox (android.widget.CheckBox)6 ViewGroup (android.view.ViewGroup)5 CompoundButton (android.widget.CompoundButton)5 ImageButton (android.widget.ImageButton)5 LinearLayout (android.widget.LinearLayout)5 ListView (android.widget.ListView)5 LayoutParams (android.widget.TableLayout.LayoutParams)5 SpannableStringBuilder (android.text.SpannableStringBuilder)4 ArrayList (java.util.ArrayList)4 Context (android.content.Context)3