當前位置: 首頁>>代碼示例>>Java>>正文


Java TableRow.setBackgroundColor方法代碼示例

本文整理匯總了Java中android.widget.TableRow.setBackgroundColor方法的典型用法代碼示例。如果您正苦於以下問題:Java TableRow.setBackgroundColor方法的具體用法?Java TableRow.setBackgroundColor怎麽用?Java TableRow.setBackgroundColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TableRow的用法示例。


在下文中一共展示了TableRow.setBackgroundColor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTableRow

import android.widget.TableRow; //導入方法依賴的package包/類
public static TableRow getTableRow(Context context, View... views){
    TableRow tableRow = new TableRow(context);
    tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT));
    tableRow.setBackgroundColor(Color.GRAY);
    for (View item: views) {
        tableRow.addView(item);
    }
    return tableRow;
}
 
開發者ID:AlexeyZatsepin,項目名稱:CP-Tester,代碼行數:11,代碼來源:ViewHelper.java

示例2: showTable

import android.widget.TableRow; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:dingdingyr,項目名稱:PullScrollView-,代碼行數:35,代碼來源:StretchViewActivity.java

示例3: showTable

import android.widget.TableRow; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:dingdingyr,項目名稱:PullScrollView-,代碼行數:35,代碼來源:PulldownViewActivity.java

示例4: inflateTable

import android.widget.TableRow; //導入方法依賴的package包/類
private static TableLayout inflateTable(Context context, String tableContent, String[] extras,
                                        boolean isFirstView, boolean isLastView) {
    TableLayout tableLayout = new TableLayout(context);
    String[] rows = tableContent.split(Content.TABLE_ROW_DIVIDER);
    int primaryColor = ContextCompat.getColor(context, R.color.colorPrimary);
    int stripColor = Color.argb(35, Color.red(primaryColor), Color.green(primaryColor), Color.blue(primaryColor));
    TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    TableRow.LayoutParams rowParams = new TableRow.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    tableLayout.setLayoutParams(tableParams);
    tableLayout.setStretchAllColumns(true);
    for (int i = 0; i < rows.length; i++) {
        TableRow tableRow = new TableRow(context);
        tableRow.setLayoutParams(rowParams);
        if (Arrays.asList(extras).contains(Content.EXTRA_HAS_STRIPES) && i % 2 != 0)
            tableRow.setBackgroundColor(stripColor);
        if (Arrays.asList(extras).contains(Content.EXTRA_HAS_HEADER) && i == 0)
            tableRow.setBackgroundResource(R.drawable.bottom_tablerow_border);
        String[] rowCells = rows[i].split(Content.TABLE_COLUMN_DIVIDER);
        for (int j = 0; j < rowCells.length; j++) {
            TextView tvCell = new TextView(context);
            tvCell.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16.0f);
            tvCell.setText(rowCells[j]);
            tvCell.setTextColor(ContextCompat.getColor(context, R.color.mainTextColor));
            int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
                    context.getResources().getDisplayMetrics());
            tvCell.setPadding(padding, i == 0 ? 0 : padding, padding, padding);
            if (Arrays.asList(extras).contains(Content.EXTRA_HAS_HEADER) && i == 0) {
                tableRow.setBackgroundResource(R.drawable.bottom_tablerow_border);
                tvCell.setTypeface(null, Typeface.BOLD);
            }
            if (j == rowCells.length - 1)
                tvCell.setGravity(GravityCompat.END);
            tableRow.addView(tvCell);
        }
        tableLayout.addView(tableRow);
    }

    if (isFirstView && isLastView)
        setViewMargins(tableLayout, 0, defaultMargin, 0, 0);
    else if (isFirstView)
        setViewMargins(tableLayout, 0, defaultMargin, 0, halfMargin);
    else if (isLastView)
        setViewMargins(tableLayout, 0, halfMargin, 0, 0);
    else
        setViewMargins(tableLayout, 0, halfMargin, 0, halfMargin);

    return tableLayout;
}
 
開發者ID:Nulltilus,項目名稱:Appmatic-Android,代碼行數:51,代碼來源:ViewParsingUtils.java

示例5: setProperties

import android.widget.TableRow; //導入方法依賴的package包/類
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++;
  }
}
 
開發者ID:jrummyapps,項目名稱:BusyBox,代碼行數:57,代碼來源:InstallerFragment.java


注:本文中的android.widget.TableRow.setBackgroundColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。