Example usage for android.widget TextView setBackgroundColor

List of usage examples for android.widget TextView setBackgroundColor

Introduction

In this page you can find the example usage for android.widget TextView setBackgroundColor.

Prototype

@RemotableViewMethod
public void setBackgroundColor(@ColorInt int color) 

Source Link

Document

Sets the background color for this view.

Usage

From source file:org.cvasilak.jboss.mobile.app.fragments.WebConnectorMetricsViewFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar();
    bar.setTitle(connectorName);//from  www .j  a v  a 2s . com

    MergeAdapter adapter = new MergeAdapter();

    TextView sectionHeader;

    // Section: General
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("General");
    adapter.addView(sectionHeader);

    MetricsAdapter generalMetricsAdapter = new MetricsAdapter(getActivity(), generalMetrics);
    adapter.addAdapter(generalMetricsAdapter);

    // Section: Request per Connector
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Request per Connector");
    adapter.addView(sectionHeader);

    MetricsAdapter reqPerConnectorMetricsAdapter = new MetricsAdapter(getActivity(), reqPerConnectorMetrics);
    adapter.addAdapter(reqPerConnectorMetricsAdapter);

    setListAdapter(adapter);
}

From source file:org.cvasilak.jboss.mobile.app.fragments.TransactionMetricsViewFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar();
    bar.setTitle(getString(R.string.transactions));

    MergeAdapter adapter = new MergeAdapter();

    TextView sectionHeader;

    // Section: Success/Failure Ratio
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Success/Failure Ratio");
    adapter.addView(sectionHeader);//from ww  w .  j av a  2  s  . c  o  m

    MetricsAdapter sucFailMetricsAdapter = new MetricsAdapter(getActivity(), sucFailMetrics);
    adapter.addAdapter(sucFailMetricsAdapter);

    // Section: Failure Origin
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Failure Origin");
    adapter.addView(sectionHeader);

    MetricsAdapter failOriginMetricsAdapter = new MetricsAdapter(getActivity(), failOriginMetrics);
    adapter.addAdapter(failOriginMetricsAdapter);

    setListAdapter(adapter);
}

From source file:com.manuelpeinado.numericpageindicator.demo.MyPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    TextView item = new TextView(container.getContext());
    item.setText(Integer.toString(position + 1));
    item.setTextColor(Color.argb(192, 255, 255, 255));
    item.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 50);
    item.setGravity(Gravity.CENTER);//from   w  ww.j  ava2s  .c o  m
    item.setBackgroundColor(COLORS[position % COLORS.length]);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    container.addView(item, layoutParams);
    return item;
}

From source file:org.cvasilak.jboss.mobile.app.fragments.DataSourceMetricsViewFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar();
    bar.setTitle(dsName);//from www.ja va 2 s .  c om

    MergeAdapter adapter = new MergeAdapter();

    TextView sectionHeader;

    // Section: Pool Usage
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Pool Usage");
    adapter.addView(sectionHeader);

    MetricsAdapter poolMetricsAdapter = new MetricsAdapter(getActivity(), poolMetrics);
    adapter.addAdapter(poolMetricsAdapter);

    // Section: Prepared Statement Pool Usage
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Prepared Statement Pool Usage");
    adapter.addView(sectionHeader);

    MetricsAdapter prepStatementMetricsAdapter = new MetricsAdapter(getActivity(), prepStatementMetrics);
    adapter.addAdapter(prepStatementMetricsAdapter);

    setListAdapter(adapter);
}

From source file:com.near.chimerarevo.fragments.ProductFragment.java

private void addTitle(String text) {
    TextView title = new TextView(getActivity());
    title.setBackgroundColor(getResources().getColor(R.color.prod_title_color));
    title.setTextColor(getResources().getColor(android.R.color.white));
    title.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "roboto_light.ttf"));
    title.setTextSize(22);/*w  w  w. j  a  v a 2s.  c o m*/
    title.setPadding(15, 10, 15, 10);

    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    title.setLayoutParams(params);

    title.setText(text);

    View div = new View(getActivity());
    div.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 2));
    div.setBackgroundColor(getResources().getColor(R.color.prod_title_color));

    lay.addView(title);
    lay.addView(div);
}

From source file:org.cvasilak.jboss.mobile.admin.fragments.ConfigurationViewFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.d(TAG, "@onCreate()");

    application = (JBossAdminApplication) getActivity().getApplication();

    // restore state in case of a configuration change (eg orientation)
    if (savedInstanceState != null) {
        confMetrics = savedInstanceState.getParcelableArrayList("confMetrics");
    }/*  w  w  w  .j  av  a2  s.c  o m*/

    MergeAdapter adapter = new MergeAdapter();

    TextView sectionHeader;

    // Section: Server Information
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Server Information");
    adapter.addView(sectionHeader);

    if (confMetrics == null) {
        confMetrics = new ArrayList<Metric>();

        confMetrics.add(new Metric("Code Name", "release-codename"));
        confMetrics.add(new Metric("Release Version", "release-version"));
        confMetrics.add(new Metric("Server State", "server-state"));
    }

    MetricsAdapter confMetricsAdapter = new MetricsAdapter(getSherlockActivity(), confMetrics);
    adapter.addAdapter(confMetricsAdapter);

    // Section: Server Configuration
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Server Configuration");
    adapter.addView(sectionHeader);
    adapter.addAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1,
            new String[] { "Extensions", "Properties" }));

    setListAdapter(adapter);

    // inform runtime that we have an action button (refresh)
    setHasOptionsMenu(true);

    // refresh only if the fragment is created
    // for the first time (no previous state)
    if (savedInstanceState == null)
        refresh();

}

From source file:org.cvasilak.jboss.mobile.app.fragments.JMSQueueMetricsViewFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar();
    bar.setTitle(queueName);//ww  w  .  ja  v a2  s.  com

    MergeAdapter adapter = new MergeAdapter();

    TextView sectionHeader;

    // Section: In-Flight Messages
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("In-Flight Messages");
    adapter.addView(sectionHeader);

    MetricsAdapter inFlightMetricsAdapter = new MetricsAdapter(getActivity(), inFlightMetrics);
    adapter.addAdapter(inFlightMetricsAdapter);

    // Section: Messages Processed
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Messages Processed");
    adapter.addView(sectionHeader);

    MetricsAdapter msgProcessedMetricsAdapter = new MetricsAdapter(getActivity(), msgProcessedMetrics);
    adapter.addAdapter(msgProcessedMetricsAdapter);

    // Section: Consumer
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Consumer");
    adapter.addView(sectionHeader);

    MetricsAdapter consumerMetricsAdapter = new MetricsAdapter(getActivity(), consumerMetrics);
    adapter.addAdapter(consumerMetricsAdapter);

    setListAdapter(adapter);
}

From source file:org.cvasilak.jboss.mobile.app.fragments.JMSTopicMetricsViewFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    ActionBar bar = ((ActionBarActivity) getActivity()).getSupportActionBar();
    bar.setTitle(topicName);/*from  w ww.ja va  2  s  . c  om*/

    MergeAdapter adapter = new MergeAdapter();

    TextView sectionHeader;

    // Section: In-Flight Messages
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("In-Flight Messages");
    adapter.addView(sectionHeader);

    MetricsAdapter inFlightMetricsAdapter = new MetricsAdapter(getActivity(), inFlightMetrics);
    adapter.addAdapter(inFlightMetricsAdapter);

    // Section: Messages Processed
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Messages Processed");
    adapter.addView(sectionHeader);

    MetricsAdapter msgProcessedMetricsAdapter = new MetricsAdapter(getActivity(), msgProcessedMetrics);
    adapter.addAdapter(msgProcessedMetricsAdapter);

    // Section: Consumer
    sectionHeader = new TextView(getActivity());
    sectionHeader.setBackgroundColor(Color.DKGRAY);
    sectionHeader.setPadding(15, 10, 0, 10);
    sectionHeader.setText("Subscriptions");
    adapter.addView(sectionHeader);

    MetricsAdapter subscriptionerMetricsAdapter = new MetricsAdapter(getActivity(), subscriptionMetrics);
    adapter.addAdapter(subscriptionerMetricsAdapter);

    setListAdapter(adapter);
}

From source file:org.exobel.routerkeygen.ui.WifiListAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    final Item wifi = getItem(position);
    if (convertView == null) {
        if (wifi.type == Item.ITEM) {
            convertView = getItemView(parent);
        } else {/*  www  .  j a  v a  2 s. com*/
            convertView = getSectionView(parent);
        }
    } else {
        switch (wifi.type) {
        case Item.ITEM:
            if (convertView.getTag() == null) {
                convertView = getItemView(parent);
            }
            break;
        case Item.SECTION:
            if (convertView.getTag() != null) {
                convertView = getSectionView(parent);
            }
            break;
        }
    }

    if (wifi.type == Item.ITEM) {
        final ViewHolder holder = (ViewHolder) convertView.getTag();
        if (holder != null) {
            holder.ssid.setText(wifi.wifiNetwork.getSsidName());
            holder.mac.setText(wifi.wifiNetwork.getMacAddress());
            final int strenght = wifi.wifiNetwork.getLevel();
            if (wifi.wifiNetwork.isLocked()) {
                holder.networkStrength.setImageDrawable(wifiSignalLocked[strenght]);
            } else {
                holder.networkStrength.setImageDrawable(wifiSignal[strenght]);
            }
        }
    } else {
        TextView view = (TextView) convertView;
        view.setText(wifi.text);
        view.setBackgroundColor(parent.getResources().getColor(wifi.color));
    }
    return convertView;
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.FeedRefObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();//from w  w  w  . j  av a2 s.com
    byte[] raw = obj.getRaw();

    TextView view = new TextView(context);
    view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    String feedName = content.optString(FEED_ID);
    view.setText(feedName);
    view.setBackgroundColor(Feed.colorFor(feedName));
    frame.addView(view);
}