Example usage for android.widget TableRow addView

List of usage examples for android.widget TableRow addView

Introduction

In this page you can find the example usage for android.widget TableRow addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:org.smap.smapTask.android.activities.TaskAddressActivity.java

/** Called when the activity is first created. */
@Override//  ww w  .j  a v a2 s .  c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.task_address);

    // Get the id of the selected list item
    Bundle bundle = getIntent().getExtras();

    taskEntry = Utilities.getTaskWithId(bundle.getLong("id"));

    try {

        //String assignment_status = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_STATUS));
        //String taskTitle = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_TITLE));
        //String taskAddress = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_ADDRESS));

        // Formatting
        LinearLayout.LayoutParams textLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        textLayout.setMargins(1, 1, 1, 1);

        TableRow.LayoutParams trLayout = new TableRow.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        trLayout.setMargins(1, 1, 1, 1);

        TableLayout tableLayout = (TableLayout) findViewById(R.id.task_address_values);

        // Add Title
        TextView title = (TextView) findViewById(R.id.task_title);
        title.setText(taskEntry.name);

        // Add Status
        TableRow r = new TableRow(this);
        r.setLayoutParams(trLayout);
        r.setBackgroundColor(0xff0000);
        TextView text1 = new TextView(this);
        text1.setText("Status");
        text1.setBackgroundColor(0xff0000);
        TextView text2 = new TextView(this);
        text2.setText(taskEntry.taskStatus);
        text2.setBackgroundColor(0xff0000);
        r.addView(text1);
        r.addView(text2);
        tableLayout.addView(r);

        // Put the Address items in the table
        Type type = new TypeToken<ArrayList<Address>>() {
        }.getType();
        ArrayList<Address> aArray = new Gson().fromJson(taskEntry.taskAddress, type);
        if (aArray != null) {
            for (int i = 0; i < aArray.size(); i++) {

                r = new TableRow(this);
                r.setLayoutParams(trLayout);
                r.setBackgroundColor(0xff0000);

                text1 = new TextView(this);
                text1.setText(aArray.get(i).name);
                text1.setBackgroundColor(0xff0000);

                text2 = new TextView(this);
                text2.setText(aArray.get(i).value);
                text2.setBackgroundColor(0xff0000);

                r.addView(text1);
                r.addView(text2);
                tableLayout.addView(r);
            }
        }

        // Create the buttons
        LinearLayout buttons = (LinearLayout) findViewById(R.id.task_address_buttons);
        //menu.setHeaderTitle(taskTitle);
        if (Utilities.canReject(taskEntry.taskStatus)) {

            Button b = new Button(this);
            b.setText("Reject Task");
            b.setId(R.id.reject_button);
            b.setOnClickListener(this);
            buttons.addView(b);
        }
        if (Utilities.canComplete(taskEntry.taskStatus)) {
            Button b = new Button(this);
            b.setText("Complete Task");
            b.setId(R.id.complete_button);
            b.setOnClickListener(this);
            buttons.addView(b);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.google.reviewit.AddReviewerFragment.java

private void addReviewerRow(TableLayout tl, AccountInfo reviewer) {
    TableRow tr = new TableRow(getContext());
    tr.setLayoutParams(matchAndWrapTableRowLayout());
    ImageView avatar = new ImageView(getContext());
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(widgetUtil.dpToPx(20),
            widgetUtil.dpToPx(20));//from w  w w  .  j  av  a  2s .  c o m
    layoutParams.setMargins(0, 0, widgetUtil.dpToPx(5), widgetUtil.dpToPx(2));
    avatar.setLayoutParams(layoutParams);

    WidgetUtil.displayAvatar(getApp(), reviewer, avatar);
    tr.addView(avatar);
    TextView reviewerName = new TextView(getContext());
    reviewerName.setLayoutParams(wrapTableRowLayout());
    reviewerName.setText(FormatUtil.format(reviewer));
    tr.addView(reviewerName);
    tl.addView(tr, matchAndWrapTableLayout());
}

From source file:org.mklab.mikity.android.editor.GroupEditor.java

private void createAnimationParameterBoxes(final View view) {
    final TableLayout parameters = ((TableLayout) view.findViewById(R.id.animation_parameters));
    parameters.removeAllViews();// w  w w.ja v a 2 s  .c  o m
    parameters.setStretchAllColumns(true);

    final TableRow head = new TableRow(getContext());
    parameters.addView(head);

    final TextView name = new TextView(getContext());
    name.setText(R.string.name);
    name.setTextColor(Color.BLACK);
    head.addView(name);

    final TextView id = new TextView(getContext());
    id.setText(R.string.id);
    id.setTextColor(Color.BLACK);
    head.addView(id);

    final TextView number = new TextView(getContext());
    number.setText(R.string.number);
    number.setTextColor(Color.BLACK);
    head.addView(number);

    createAnimationTranslationBoxes(parameters);
    createAnimationRotationBoxes(parameters);

    setAnimationInDialog();
}

From source file:com.health.openscale.gui.TableFragment.java

@Override
public void updateOnView(ArrayList<ScaleData> scaleDataList) {
    TableRow headerRow = (TableRow) tableView.findViewById(R.id.tableHeader);
    tableDataView.removeAllViews();/*from  ww  w . j  ava2s.  c  o m*/
    tableDataView.addView(headerRow);

    for (ScaleData scaleData : scaleDataList) {
        TableRow dataRow = new TableRow(tableView.getContext());
        dataRow.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        TextView idView = new TextView(tableView.getContext());
        idView.setText(Long.toString(scaleData.id));
        idView.setVisibility(View.GONE);
        dataRow.addView(idView);

        TextView dateTextView = new TextView(tableView.getContext());
        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE
                || (getResources().getConfiguration().screenLayout
                        & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
            dateTextView.setText(new SimpleDateFormat("dd. MMM yyyy (EE)").format(scaleData.date_time));
        } else {
            dateTextView.setText(new SimpleDateFormat("dd/MM/yy").format(scaleData.date_time));
        }
        dateTextView.setPadding(0, 5, 5, 5);
        dataRow.addView(dateTextView);

        TextView timeTextView = new TextView(tableView.getContext());
        timeTextView.setText(new SimpleDateFormat("HH:mm").format(scaleData.date_time));
        timeTextView.setPadding(0, 5, 5, 5);
        dataRow.addView(timeTextView);

        TextView weightView = new TextView(tableView.getContext());
        weightView.setText(Float.toString(scaleData.weight));
        weightView.setPadding(0, 5, 5, 5);
        dataRow.addView(weightView);

        TextView fatView = new TextView(tableView.getContext());
        fatView.setText(Float.toString(scaleData.fat));
        fatView.setPadding(0, 5, 5, 5);
        dataRow.addView(fatView);

        TextView waterView = new TextView(tableView.getContext());
        waterView.setText(Float.toString(scaleData.water));
        waterView.setPadding(0, 5, 5, 5);
        dataRow.addView(waterView);

        TextView muscleView = new TextView(tableView.getContext());
        muscleView.setText(Float.toString(scaleData.muscle));
        muscleView.setPadding(0, 5, 5, 5);
        dataRow.addView(muscleView);

        Button deleteButton = new Button(tableView.getContext());
        deleteButton.setText("X");
        deleteButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
        deleteButton.setTextColor(Color.WHITE);
        deleteButton.setBackgroundResource(R.drawable.flat_selector);
        deleteButton.setGravity(Gravity.CENTER);
        deleteButton.setPadding(0, 0, 0, 0);
        deleteButton.setMinimumHeight(35);
        deleteButton.setHeight(35);
        deleteButton.setOnClickListener(new onClickListenerDelete());
        dataRow.addView(deleteButton);

        if ((getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_XLARGE
                && (getResources().getConfiguration().screenLayout
                        & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_LARGE) {
            dateTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            timeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            weightView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            fatView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            waterView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
            muscleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 11);
        }

        tableDataView.addView(dataRow,
                new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    }
}

From source file:de.uulm.graphicalpasswords.opentapi.TAPILoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tapi_login);
    // Show the Up button in the action bar.
    setupActionBar();/*from  ww w .jav  a  2s .c  o  m*/

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    length = Integer.parseInt(sharedPref.getString("tapi_length", "6"));
    password = sharedPref.getString("tapi_pw", "");
    input = new String[length];

    for (int i = 0; i < images.length; i++) {
        images[i] = sharedPref.getInt("image" + i, 0);
    }

    EditText editText = (EditText) findViewById(R.id.tapi_edittext);
    text = editText.getText();
    back = (Button) findViewById(R.id.tapi_back);
    clear = (Button) findViewById(R.id.tapi_clear);
    save = (Button) findViewById(R.id.tapi_save);

    TableLayout table = (TableLayout) findViewById(R.id.tapi_imagetable);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    TableRow row = null;
    for (int i = 0; i < imageViews.length; i++) {
        if (i % 4 == 0) {
            row = new TableRow(this);
        }
        imageViews[i] = new PassImageView(this);
        imageViews[i].setLayoutParams(layoutParams);
        imageViews[i].setAdjustViewBounds(true);
        imageViews[i].setScaleType(ScaleType.CENTER_INSIDE);
        imageViews[i].setPadding(5, 5, 5, 5);
        imageViews[i].setImageResource(images[i]);
        row.addView(imageViews[i]);
        if (i % 4 == 3) {
            table.addView(row);
        }
        imageViews[i].setOnTouchListener(new TAPIOnTouchListener(this, imageViews[i]));
    }
}

From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java

private void addTableRowSpacer() {
    Context context = getActivity();
    TableRow tableRow = new TableRow(context);
    View spacerView = new View(context);
    int spacerHeight = (int) (getResources().getDisplayMetrics().density
            * getResources().getDimension(R.dimen.network_info_spacer_height) + 0.5f);
    spacerView.setLayoutParams(new TableRow.LayoutParams(1, spacerHeight));
    tableRow.addView(spacerView);
    mNetworkInfoTableLayout.addView(tableRow);
}

From source file:de.uulm.graphicalpasswords.opentapi.TAPICreatePasswordActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tapi_create_password);

    // Show the Up button in the action bar.
    setupActionBar();/*  ww w .jav a  2s  .co m*/

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    length = Integer.parseInt(sharedPref.getString("tapi_length", "6"));
    input = new String[length];

    // Save Pictures in randomized order
    SharedPreferences.Editor editor = sharedPref.edit();
    Random random = new Random(System.currentTimeMillis());
    boolean[] usedImages = new boolean[TAPIActivity.IMAGES.length];
    Arrays.fill(usedImages, false);
    for (int i = 0; i < TAPIActivity.IMAGES.length; i++) {
        boolean pictureSet = false;
        int index = random.nextInt(TAPIActivity.IMAGES.length);
        do {
            if (!usedImages[index]) {
                editor.putInt("image" + i, TAPIActivity.IMAGES[index]);
                pictureSet = true;
                usedImages[index] = true;
            } else if (index == TAPIActivity.IMAGES.length - 1) {
                index = 0;
            } else {
                index++;
            }
        } while (!pictureSet);
    }
    editor.commit();

    for (int i = 0; i < images.length; i++) {
        images[i] = sharedPref.getInt("image" + i, 0);
    }

    EditText editText = (EditText) findViewById(R.id.tapi_edittext);
    text = editText.getText();
    back = (Button) findViewById(R.id.tapi_back);
    save = (Button) findViewById(R.id.tapi_save);

    TableLayout table = (TableLayout) findViewById(R.id.tapi_imagetable);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    TableRow row = null;
    for (int i = 0; i < imageViews.length; i++) {
        if (i % 4 == 0) {
            row = new TableRow(this);
        }
        imageViews[i] = new PassImageView(this);
        imageViews[i].setLayoutParams(layoutParams);
        imageViews[i].setAdjustViewBounds(true);
        imageViews[i].setScaleType(ScaleType.CENTER_INSIDE);
        imageViews[i].setPadding(5, 5, 5, 5);
        imageViews[i].setImageResource(images[i]);
        row.addView(imageViews[i]);
        if (i % 4 == 3) {
            table.addView(row);
        }
        imageViews[i].setOnTouchListener(new TAPIOnTouchListener(this, imageViews[i]));
    }

    Bundle bundle = new Bundle();
    bundle.putInt("length", length);
    DialogFragment intro = new IntroDialogFragment();
    intro.setArguments(bundle);
    intro.show(getFragmentManager(), "intro");
}

From source file:de.uulm.graphicalpasswords.openuyi.UYIPagerAdapter.java

@Override
public Object instantiateItem(View collection, int pos) {
    LayoutInflater inflater = (LayoutInflater) collection.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    int page = 0;

    switch (pos) {
    case 1://from   w w w  . ja  v a  2  s .co m
        page = R.layout.uyipage2;
        break;
    case 2:
        page = R.layout.uyipage3;
        break;
    default:
        page = R.layout.uyipage1;
        break;
    }

    View view = inflater.inflate(page, null);
    TableLayout currentTable;

    switch (pos) {
    case 1:
        currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page2);
        break;
    case 2:
        currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page3);
        break;
    default:
        currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page1);
        break;
    }

    // Add ImageButtons to TableLayout
    int index = 0;
    for (int i = 0; i < 3; i++) {
        TableRow currentRow = new TableRow(view.getContext());
        for (int j = 0; j < 3; j++) {
            ImageButton button = new ImageButton(view.getContext());
            button.setBackgroundColor(Color.TRANSPARENT);
            button.setPadding(3, 3, 3, 3);
            button.setAdjustViewBounds(true);
            button.setOnClickListener(clickListener);
            button.setImageResource(picture_arrays[pos][index]);
            button.setId(picture_arrays[pos][index]);
            button.setClickable(true);
            index++;
            currentRow.addView(button);
        }
        currentTable.addView(currentRow);
    }

    ((ViewPager) collection).addView(view, 0);

    return view;
}

From source file:com.mikecorrigan.trainscorekeeper.FragmentSummary.java

@SuppressLint("NewApi")
@Override/*from ww w . ja  v a 2 s.  c  o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.vc(VERBOSE, TAG, "onCreateView: inflater=" + inflater + ", container=" + container
            + ", savedInstanceState=" + Utils.bundleToString(savedInstanceState));

    View rootView = inflater.inflate(R.layout.fragment_summary, container, false);

    final MainActivity activity = (MainActivity) getActivity();
    final Context context = activity;
    final Resources resources = context.getResources();

    // Get the model and attach a listener.
    game = activity.getGame();
    if (game != null) {
        game.addListener(mGameListener);
    }

    players = activity.getPlayers();

    // Get resources.
    String[] playerNames = resources.getStringArray(R.array.playerNames);

    TypedArray drawablesArray = resources.obtainTypedArray(R.array.playerDrawables);

    TypedArray playerTextColorsArray = resources.obtainTypedArray(R.array.playerTextColors);
    int[] playerTextColorsIds = new int[playerTextColorsArray.length()];
    for (int i = 0; i < playerTextColorsArray.length(); i++) {
        playerTextColorsIds[i] = playerTextColorsArray.getResourceId(i, -1);
    }

    // Get root view.
    ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.scroll_view);

    // Create table.
    tableLayout = new TableLayout(context);
    TableLayout.LayoutParams tableLayoutParams = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    tableLayout.setLayoutParams(tableLayoutParams);
    scrollView.addView(tableLayout);

    // Add header.
    {
        TableRow row = new TableRow(context);
        row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        tableLayout.addView(row);

        TextView tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.player));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.trains));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.contracts));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(resources.getString(R.string.bonuses));
        tv.setTypeface(null, Typeface.BOLD);
        row.addView(tv);

    }

    // Add rows.
    for (int i = 0; i < players.getNum(); i++) {
        TableRow row = new TableRow(context);
        row.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        tableLayout.addView(row);

        ToggleButton toggleButton = new ToggleButton(context);
        toggleButton.setGravity(Gravity.CENTER);
        toggleButton.setPadding(10, 10, 10, 10);
        toggleButton.setText(playerNames[i]);
        toggleButton.setClickable(false);
        Drawable drawable = drawablesArray.getDrawable(i);
        int sdk = android.os.Build.VERSION.SDK_INT;
        if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
            toggleButton.setBackgroundDrawable(drawable);
        } else {
            toggleButton.setBackground(drawable);
        }
        toggleButton.setTextColor(resources.getColor(playerTextColorsIds[i]));
        row.addView(toggleButton);

        TextView tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        row.addView(tv);

        tv = new TextView(context);
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(10, 10, 10, 10);
        row.addView(tv);

    }

    Bundle args = getArguments();
    if (args == null) {
        Log.e(TAG, "onCreateView: missing arguments");
        return rootView;
    }

    drawablesArray.recycle();
    playerTextColorsArray.recycle();

    // final int index = args.getInt(ARG_INDEX);
    // final String tabSpec = args.getString(ARG_TAB_SPEC);

    return rootView;
}

From source file:org.mklab.mikity.android.editor.GroupEditor.java

private void createCoordinateParameterBoxes(final View view) {
    final TableLayout parameters = ((TableLayout) view.findViewById(R.id.coordinate_parameters));
    parameters.removeAllViews();/*from  w  ww.  j av  a2s  . c  om*/
    parameters.setStretchAllColumns(true);

    final TableRow head = new TableRow(getContext());
    final TextView name = new TextView(getContext());
    name.setText(R.string.name);
    name.setTextColor(Color.BLACK);
    final TextView value = new TextView(getContext());
    value.setText(R.string.value);
    value.setTextColor(Color.BLACK);
    head.addView(name);
    head.addView(value);
    parameters.addView(head);

    createCoordinateTranslationBoxes(parameters);
    createCoordinateRotationBoxes(parameters);
}