Java Code Examples for android.widget.TableRow#setBackgroundColor()

The following examples show how to use android.widget.TableRow#setBackgroundColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StretchViewActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 2
Source File: PulldownViewActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
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 < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down 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(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 3
Source File: StretchViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 4
Source File: PulldownViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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 < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down 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(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 5
Source File: StretchViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 6
Source File: PulldownViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
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 < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down 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(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 7
Source File: StretchViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 8
Source File: PulldownViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
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 < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down 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(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 9
Source File: InstallerFragment.java    From BusyBox with Apache License 2.0 4 votes vote down vote up
private void setProperties(ArrayList<FileMeta> properties) {
  this.properties = properties;

  if (properties == null) {
    propertiesCard.setVisibility(View.GONE);
    return;
  }
  if (propertiesCard.getVisibility() != View.VISIBLE) {
    propertiesCard.setVisibility(View.VISIBLE);
  }

  Analytics.EventBuilder analytics = Analytics.newEvent("busybox properties");
  for (FileMeta property : properties) {
    analytics.put(property.label, property.value);
  }
  analytics.log();

  TableLayout tableLayout = getViewById(R.id.table_properties);

  if (tableLayout.getChildCount() > 0) {
    tableLayout.removeAllViews();
  }

  int width = ResUtils.dpToPx(128);
  int left = ResUtils.dpToPx(16);
  int top = ResUtils.dpToPx(6);
  int bottom = ResUtils.dpToPx(6);

  int i = 0;
  for (FileMeta meta : properties) {
    TableRow tableRow = new TableRow(getActivity());
    TextView nameText = new TextView(getActivity());
    TextView valueText = new TextView(getActivity());

    if (i % 2 == 0) {
      tableRow.setBackgroundColor(0x0D000000);
    } else {
      tableRow.setBackgroundColor(Color.TRANSPARENT);
    }

    nameText.setLayoutParams(new TableRow.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
    nameText.setPadding(left, top, 0, bottom);
    nameText.setAllCaps(true);
    nameText.setTypeface(Typeface.DEFAULT_BOLD);
    nameText.setText(meta.name);

    valueText.setPadding(left, top, 0, bottom);
    valueText.setText(meta.value);

    tableRow.addView(nameText);
    tableRow.addView(valueText);
    tableLayout.addView(tableRow);

    i++;
  }
}
 
Example 10
Source File: MainFragmentBase.java    From TowerCollector with Mozilla Public License 2.0 4 votes vote down vote up
private void showWarning(TableRow tableRow, TextView label, boolean show) {
    Timber.d("showWarning(): Setting warning visible = %s", show);
    label.setTextColor(getResources().getColor(R.color.text_light));
    tableRow.setBackgroundColor(getResources().getColor(R.color.background_needs_attention));
    tableRow.setVisibility(show ? View.VISIBLE : View.GONE);
}