Example usage for android.widget TextView setHeight

List of usage examples for android.widget TextView setHeight

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setHeight(int pixels) 

Source Link

Document

Sets the height of the TextView to be exactly pixels tall.

Usage

From source file:com.hybris.mobile.adapter.BasketAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    CartItem cartItem = items.get(position);
    View rowView = null;//from w  w w .  ja va2s  . co m

    if (cartItem instanceof CartEntry) {
        CartEntry cartEntry = (CartEntry) cartItem;

        rowView = inflater.inflate(R.layout.cart_row, parent, false);

        TextView lblProductTitle = (TextView) rowView.findViewById(R.id.lbl_product_title);
        TextView lblProductPrice = (TextView) rowView.findViewById(R.id.lbl_price_quantity);
        TextView lblManufacturer = (TextView) rowView.findViewById(R.id.lbl_productManufacturer);
        TextView lblTotal = (TextView) rowView.findViewById(R.id.lbl_total);
        ImageView productImage = (ImageView) rowView.findViewById(R.id.img_product);

        if (StringUtils.isEmpty(cartEntry.getProduct().getManufacturer())) {
            lblManufacturer.setHeight(0);
        } else {
            lblManufacturer.setText(cartEntry.getProduct().getManufacturer());
        }
        lblProductTitle.setText(cartEntry.getProduct().getName());
        lblProductPrice.setText(cartEntry.getBasePrice().getFormattedValue() + " - "
                + this.getContext().getString(R.string.cartentry_quantity_placeholder)
                + cartEntry.getQuantity().toString());
        lblManufacturer.setText(cartEntry.getProduct().getManufacturer());

        lblTotal.setText(cartEntry.getTotalPrice().getFormattedValue());
        UrlImageViewHelper.setUrlDrawable(productImage, cartEntry.getProduct().getThumbnail(),
                R.drawable.loading_drawable);
    }

    return rowView;
}

From source file:com.hybris.mobile.adapter.CartAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    Object cartItem = items.get(position);
    View rowView = null;//w w  w. j av a  2s .  c  o  m

    if (cartItem instanceof CartEntry) {
        CartEntry cartEntry = (CartEntry) cartItem;

        rowView = inflater.inflate(R.layout.cart_row, parent, false);

        TextView lblProductTitle = (TextView) rowView.findViewById(R.id.lbl_product_title);
        TextView lblProductPrice = (TextView) rowView.findViewById(R.id.lbl_price_quantity);
        TextView lblManufacturer = (TextView) rowView.findViewById(R.id.lbl_productManufacturer);
        TextView lblTotal = (TextView) rowView.findViewById(R.id.lbl_total);
        ImageView productImage = (ImageView) rowView.findViewById(R.id.img_product);

        if (StringUtils.isEmpty(cartEntry.getProduct().getManufacturer())) {
            lblManufacturer.setHeight(0);
        } else {
            lblManufacturer.setText(cartEntry.getProduct().getManufacturer());
        }
        lblProductTitle.setText(cartEntry.getProduct().getName());
        lblProductPrice.setText(cartEntry.getBasePrice().getFormattedValue() + " - "
                + this.getContext().getString(R.string.cartentry_quantity_placeholder)
                + cartEntry.getQuantity().toString());
        lblManufacturer.setText(cartEntry.getProduct().getManufacturer());

        lblTotal.setText(cartEntry.getTotalPrice().getFormattedValue());
        UrlImageViewHelper.setUrlDrawable(productImage, cartEntry.getProduct().getThumbnail(),
                R.drawable.loading_drawable);
    }
    // Promotions
    else if (cartItem instanceof CartPromotion) {
        CartPromotion cartPromotion = (CartPromotion) cartItem;

        rowView = inflater.inflate(R.layout.promotion_row, parent, false);

        // Update promotions section
        TextView promotionsTextView = (TextView) rowView.findViewById(R.id.textView);
        promotionsTextView.setMovementMethod(LinkMovementMethod.getInstance());

        promotionsTextView.setText(Html.fromHtml(Cart.generatePromotionString(cartPromotion)));
        StringUtil.removeUnderlines((Spannable) promotionsTextView.getText());
    }

    return rowView;
}

From source file:org.akvo.caddisfly.ui.MainActivity.java

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {

    final Activity activity = this;
    if (requestCode == PERMISSION_ALL) {
        // If request is cancelled, the result arrays are empty.
        boolean granted = false;
        for (int grantResult : grantResults) {
            if (grantResult != PERMISSION_GRANTED) {
                granted = false;//from   ww w.  ja  va  2 s.  c om
                break;
            } else {
                granted = true;
            }
        }
        if (granted) {
            startStripTest();
        } else {
            String message = getString(R.string.storagePermission);
            if (AppPreferences.useExternalCamera()) {
                message = getString(R.string.storagePermission);
            }
            Snackbar snackbar = Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
                    .setAction("SETTINGS", new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            ApiUtil.startInstalledAppDetailsActivity(activity);
                        }
                    });

            TypedValue typedValue = new TypedValue();
            getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);

            snackbar.setActionTextColor(typedValue.data);
            View snackView = snackbar.getView();
            TextView textView = (TextView) snackView.findViewById(android.support.design.R.id.snackbar_text);
            textView.setHeight(getResources().getDimensionPixelSize(R.dimen.snackBarHeight));
            textView.setLineSpacing(0, SNACK_BAR_LINE_SPACING);
            textView.setTextColor(Color.WHITE);
            snackbar.show();
        }
    }
}

From source file:com.duckduckgo.mobile.android.views.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from   w w  w.  jav  a2  s. c  o m
 */
protected TextView createDefaultTabView(Context context) {
    TextView textView = new TextView(context);
    textView.setGravity(Gravity.TOP | Gravity.CENTER);
    textView.setTextAppearance(context, R.style.TabTitle);
    textView.setHeight((int) getResources().getDimension(R.dimen.actionbar_tab_height2));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        textView.setBackgroundResource(outValue.resourceId);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style
        textView.setAllCaps(true);
    }

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    int halfPadding = (int) (padding * 0.5);
    //textView.setPadding(padding, padding, padding, padding);
    textView.setPadding(padding, halfPadding, padding, padding);

    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    int width;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point size = new Point();
        display.getSize(size);
        width = size.x;
    } else {
        width = display.getWidth();
    }

    if (width > getResources().getDimension(R.dimen.tab_small)
            || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        textView.setWidth(width / mViewPager.getAdapter().getCount());
    }

    return textView;
}

From source file:at.flack.FacebookMainActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (((MainActivity) getActivity()).existsCookie()) {
        View rootView = inflater.inflate(R.layout.fragment_fb_main, container, false);

        contactList = (ListView) rootView.findViewById(R.id.listview);
        loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false));
        cantloadContacts = rootView.findViewById(R.id.nothing_found);

        TextView padding = new TextView(getActivity());
        padding.setHeight(10);
        contactList.addHeaderView(padding);
        contactList.setHeaderDividersEnabled(false);
        contactList.addFooterView(loadmore.getView(), null, false);
        contactList.setFooterDividersEnabled(false);
        smiley_helper = new SmileyKonverter();
        swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
        swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override//  ww  w  .j  a va  2  s  . c  o  m
            public void onRefresh() {
                if (getActivity() instanceof MainActivity)
                    ((MainActivity) getActivity()).facebookLogin();
            }
        });
        contactList.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0
                        : contactList.getChildAt(0).getTop();
                swipe.setEnabled(topRowVerticalPosition >= 0);
            }
        });

        loadmore.getView().setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                loadmore.setEnabled(false);
                loadMore();
            }
        });

        setProgressbar(rootView.findViewById(R.id.load_screen));
        if (MainActivity.getFbcontacts() == null)
            getProgressbar().setVisibility(View.VISIBLE);
        updateContacts(getActivity());
        contactList.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                openMessageActivity(getActivity(), arg2 - 1);
            }

        });

        FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
        fab.attachToListView(contactList);

        fab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent qr = new Intent(getActivity(), NewFbContactActivity.class);
                startActivityForResult(qr, 1);
            }
        });

        updateProfilePictures(getActivity());

        setRetainInstance(true);

        return rootView;
    } else {
        View rootView = inflater.inflate(R.layout.fragment_facebook_login, container, false);
        final EditText mail = (EditText) rootView.findViewById(R.id.email);
        final EditText password = (EditText) rootView.findViewById(R.id.password);
        final Button login_button = (Button) rootView.findViewById(R.id.login_button);

        login_button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mail.getText().length() <= 0) {
                    Toast.makeText(FacebookMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_mail),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
                if (password.getText().length() <= 0) {
                    Toast.makeText(FacebookMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_pw),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
                login_button.setEnabled(false);
                login_button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
                if (((MainActivity) getActivity()).facebookLogin(mail.getText().toString(),
                        password.getText().toString())) {
                } else {
                    Toast.makeText(FacebookMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_incorrect_or_offline),
                            Toast.LENGTH_SHORT).show();
                    password.setText("");
                    login_button.getBackground().setColorFilter(null);
                    login_button.setEnabled(true);
                }
            }
        });

        setRetainInstance(true);

        return rootView;
    }
}

From source file:at.flack.MailMainActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    prefs = getActivity().getSharedPreferences("mail", Context.MODE_PRIVATE);
    if (!prefs.getString("mailaddress", "").equals("")) {
        View rootView = inflater.inflate(R.layout.fragment_mail_main, container, false);

        loadmore = new LoadMoreAdapter(inflater.inflate(R.layout.contacts_loadmore, contactList, false));
        contactList = (ListView) rootView.findViewById(R.id.listview);
        TextView padding = new TextView(getActivity());
        padding.setHeight(10);
        contactList.addHeaderView(padding);
        contactList.setHeaderDividersEnabled(false);
        contactList.addFooterView(loadmore.getView(), null, false);
        contactList.setFooterDividersEnabled(false);
        progressbar = rootView.findViewById(R.id.load_screen);
        FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
        fab.attachToListView(contactList);
        fab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent newMail = new Intent(getActivity(), NewMailActivity.class);
                getActivity().startActivity(newMail);
            }// w  ww  .j a  v a2s.  c om
        });

        progressbar = rootView.findViewById(R.id.load_screen);
        if (MainActivity.getMailcontacts() == null)
            progressbar.setVisibility(View.VISIBLE);
        updateContactList(((MainActivity) this.getActivity()));

        swipe = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_container);
        swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                if (getActivity() instanceof MainActivity) {
                    MainActivity.mailprofile = null;
                    ((MainActivity) getActivity()).emailLogin(1, 0, limit);
                }

            }
        });
        contactList.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {

            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                int topRowVerticalPosition = (contactList == null || contactList.getChildCount() == 0) ? 0
                        : contactList.getChildAt(0).getTop();
                swipe.setEnabled(topRowVerticalPosition >= 0);
            }
        });

        contactList.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                if (MainActivity.getListItems() == null) {
                    updateContactList((MainActivity) getActivity());
                }
                openMessageActivity(getActivity(), arg2 - 1);
            }

        });

        loadmore.getView().setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                loadmore.setEnabled(false);
                MainActivity.mailprofile = null;
                limit += 12;
                ((MainActivity) getActivity()).emailLogin(1, 0, limit);
            }
        });

        setRetainInstance(true);
        return rootView;
    } else {
        View rootView = inflater.inflate(R.layout.fragment_email_login, container, false);
        final EditText mail = (EditText) rootView.findViewById(R.id.email);
        final EditText password = (EditText) rootView.findViewById(R.id.password);

        final EditText host = (EditText) rootView.findViewById(R.id.host);
        final EditText port = (EditText) rootView.findViewById(R.id.port);
        final EditText smtphost = (EditText) rootView.findViewById(R.id.smtphost);
        final EditText smtpport = (EditText) rootView.findViewById(R.id.smtpport);

        final Button login_button = (Button) rootView.findViewById(R.id.login_button);

        final RadioGroup radioGroup = (RadioGroup) rootView.findViewById(R.id.radioGroup);
        final RadioButton imap = (RadioButton) rootView.findViewById(R.id.radioButtonImap);

        radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                host.setVisibility(View.VISIBLE);
                port.setVisibility(View.VISIBLE);
                smtphost.setVisibility(View.VISIBLE);
                smtpport.setVisibility(View.VISIBLE);
            }
        });

        login_button.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                int at = mail.getText().toString().indexOf("@");
                int dot = mail.getText().toString().lastIndexOf(".");
                if (mail.getText().length() <= 0 || at < 0 || dot < 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_mail),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
                if (password.getText().length() <= 0) {
                    Toast.makeText(MailMainActivity.this.getActivity(),
                            getResources().getString(R.string.facebook_login_please_enter_valid_pw),
                            Toast.LENGTH_SHORT).show();
                    return;
                }

                String hostPart = mail.getText().toString().substring(at + 1, dot);

                MailAccounts mailacc = null;
                try {
                    mailacc = MailAccounts.valueOf(hostPart.toUpperCase(Locale.GERMAN));
                } catch (IllegalArgumentException e) {
                }
                if (mailacc == null) {
                    radioGroup.setVisibility(View.VISIBLE);
                    if (host.getText().toString().isEmpty() || port.getText().toString().isEmpty()
                            || smtphost.getText().toString().isEmpty()
                            || smtpport.getText().toString().isEmpty()) {
                        Toast.makeText(MailMainActivity.this.getActivity(),
                                MailMainActivity.this.getActivity().getResources().getString(
                                        R.string.activity_mail_enter_more_information),
                                Toast.LENGTH_LONG).show();
                        return;
                    }
                    prefs.edit().putString("mailsmtp", smtphost.getText().toString()).apply();
                    prefs.edit().putInt("mailsmtpport", Integer.parseInt(smtpport.getText().toString()));
                    prefs.edit().putString("mailimap", host.getText().toString()).apply();
                    prefs.edit().putInt("mailimapport", Integer.parseInt(port.getText().toString())).apply();
                    prefs.edit().putBoolean("mailuseimap", imap.isChecked()).apply();
                }

                login_button.setEnabled(false);
                login_button.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
                prefs.edit().putString("mailaddress", mail.getText().toString()).apply();
                prefs.edit().putString("mailpassword", password.getText().toString()).apply();

                if (mailacc != null) {
                    prefs.edit().putString("mailsmtp", mailacc.getSmtpHost()).apply();
                    prefs.edit().putInt("mailsmtpport", mailacc.getSMTPPort());
                    prefs.edit().putString("mailimap", mailacc.getHost()).apply();
                    prefs.edit().putInt("mailimapport", mailacc.getPort()).apply();
                    prefs.edit().putBoolean("mailuseimap", true).apply();
                }

                prefs.edit().commit();
                ((MainActivity) getActivity()).emailLogin(0);
            }
        });

        setRetainInstance(true);

        return rootView;
    }
}

From source file:com.gmobi.poponews.widget.PagerSlidingTabStrip.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    int px = DipHelper.dip2px(50);

    tab.setHeight(px);
    px = DipHelper.dip2px(90);/*from  w w w. j ava  2s  .co m*/
    tab.setPadding(20, 0, 20, 0);
    tab.setText(title);

    tab.setTextAppearance(this.getContext(), R.style.TabTextStyle);
    tab.setGravity(Gravity.CENTER);
    tab.setShadowLayer((float) 0.01, 0, (float) 1.0, 0xffffff);

    addTab(position, tab);
}

From source file:com.shome.app.PagerSlidingTabStrip.java

private void addIconTextTab(final int position, Drawable resDrawable, CharSequence title) {
    TextView tab = new TextView(getContext());
    tab.setCompoundDrawablesWithIntrinsicBounds(null, resDrawable, null, null);
    tab.setHeight(25);
    tab.setText(title);//  ww w . j a va2s . c  o  m
    tab.setGravity(Gravity.CENTER);
    //tab.
    //tab.setElevation(50);
    addTab(position, tab);
}

From source file:org.nla.tarotdroid.lib.ui.GameSetSynthesisFragment.java

/**
  * Refreshes the stats rows on the synthesis view.
  */// w  ww  .  j  a  v  a2  s  .c  om
protected void refreshPlayerStatsRows() {
    // sort players
    List<Player> sortedPlayers = this.getGameSet().getPlayers().getPlayers();
    Collections.sort(sortedPlayers, new PlayerScoreComparator());

    // get general data sources
    IGameSetStatisticsComputer gameSetStatisticsComputer = GameSetStatisticsComputerFactory
            .GetGameSetStatisticsComputer(this.getGameSet(), "guava");
    MapPlayersScores lastScores = this.getGameSet().getGameSetScores().getResultsAtLastGame();
    Map<Player, Integer> leadingCount = gameSetStatisticsComputer.getLeadingCount();
    Map<Player, Integer> leadingSuccesses = gameSetStatisticsComputer.getLeadingSuccessCount();
    Map<Player, Integer> calledCount = gameSetStatisticsComputer.getCalledCount();
    int minScoreEver = gameSetStatisticsComputer.getMinScoreEver();
    int maxScoreEver = gameSetStatisticsComputer.getMaxScoreEver();

    // format statistics lines
    for (int rank = 0; rank < sortedPlayers.size(); ++rank) {
        // get player specific data sources
        Player player = sortedPlayers.get(rank);
        int lastScore = lastScores == null ? 0 : lastScores.get(player);
        int successfulLeadingGamesCount = leadingSuccesses.get(player) == null ? 0
                : leadingSuccesses.get(player).intValue();
        int leadingGamesCount = leadingCount.get(player) == null ? 0 : leadingCount.get(player);
        int successRate = (int) (((double) successfulLeadingGamesCount) / ((double) leadingGamesCount) * 100.0);
        int minScoreForPlayer = gameSetStatisticsComputer.getMinScoreEverForPlayer(player);
        int maxScoreForPlayer = gameSetStatisticsComputer.getMaxScoreEverForPlayer(player);

        // get line widgets
        LinearLayout statRow = this.statsRows.get(rank + 1);
        //TextView statPlayerName = (TextView)statRow.findViewById(R.id.statPlayerName);
        TextView statScore = (TextView) statRow.findViewById(R.id.statScore);
        TextView statLeadingGamesCount = (TextView) statRow.findViewById(R.id.statLeadingGamesCount);
        TextView statSuccessfulGamesCount = (TextView) statRow.findViewById(R.id.statSuccessfulGamesCount);
        TextView statMinScore = (TextView) statRow.findViewById(R.id.statMinScore);
        TextView statMaxScore = (TextView) statRow.findViewById(R.id.statMaxScore);

        //          Bitmap playerImage = null;
        //          if (player.getPictureUri() != null && !player.getPictureUri().equals("")) {
        //             playerImage = UIHelper.getPlayerImage(this.getActivity(), player);
        //          }
        //          
        //            
        //            // assign values to widgets
        //            if (player.getFacebookId() != null) {
        //             // player facebook image
        //             ProfilePictureView pictureView = new ProfilePictureView(this.getActivity());
        //             pictureView.setProfileId(player.getFacebookId());
        //             pictureView.setPresetSize(ProfilePictureView.SMALL);
        //             //pictureView.setOnClickListener(playerClickListener);
        //             pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);
        //             statRow.removeViewAt(0);
        //               statRow.addView(pictureView, 0);
        //            }
        //            else {
        //               // WARNING: The properties below reference the style ScoreTextStyle, but we can't set a style at runtime.
        //               TextView playerName = new TextView(this.getActivity());
        //               playerName.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1));
        //               playerName.setGravity(Gravity.CENTER);
        //               playerName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
        //               playerName.setEllipsize(TruncateAt.END);
        //               playerName.setSingleLine();
        //               playerName.setTextColor(Color.WHITE);
        //               playerName.setTypeface(null, Typeface.BOLD);
        //               playerName.setText(player.getName());
        //               //playerName.setBackgroundResource(R.drawable.border_player_white);
        //               statRow.removeViewAt(0);
        //               statRow.addView(playerName, 0);
        //            }

        OnClickListener playerClickListener = new PlayerClickListener(player);

        // facebook picture
        if (player.getFacebookId() != null) {
            ProfilePictureView pictureView = new ProfilePictureView(this.getActivity());
            pictureView.setProfileId(player.getFacebookId());
            pictureView.setPresetSize(ProfilePictureView.SMALL);
            pictureView.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);

            pictureView.setOnClickListener(playerClickListener);
            //this.addView(pictureView);
            statRow.removeViewAt(0);
            statRow.addView(pictureView, 0);
        }

        // contact picture
        else if (player.getPictureUri() != null
                && player.getPictureUri().toString().contains("content://com.android.contacts/contacts")) {
            Bitmap playerImage = UIHelper.getContactPicture(this.getActivity(),
                    Uri.parse(player.getPictureUri()).getLastPathSegment());
            ImageView imgPlayer = new ImageView(this.getActivity());
            imgPlayer.setImageBitmap(playerImage);
            imgPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);

            imgPlayer.setOnClickListener(playerClickListener);
            //this.addView(imgPlayer);
            statRow.removeViewAt(0);
            statRow.addView(imgPlayer, 0);
        }

        // no picture, only name
        else {
            TextView txtPlayer = new TextView(this.getActivity());
            txtPlayer.setText(player.getName());
            txtPlayer.setGravity(Gravity.CENTER);
            txtPlayer.setLayoutParams(UIConstants.PLAYERS_LAYOUT_PARAMS);
            txtPlayer.setMinWidth(UIConstants.PLAYER_VIEW_WIDTH);
            txtPlayer.setHeight(UIConstants.PLAYER_VIEW_HEIGHT);
            txtPlayer.setBackgroundColor(Color.TRANSPARENT);
            txtPlayer.setTypeface(null, Typeface.BOLD);
            txtPlayer.setTextColor(Color.WHITE);
            txtPlayer.setSingleLine();
            txtPlayer.setEllipsize(TruncateAt.END);

            txtPlayer.setOnClickListener(playerClickListener);
            //this.addView(txtPlayer);
            statRow.removeViewAt(0);
            statRow.addView(txtPlayer, 0);
        }

        statScore.setText(Integer.toString(lastScore));
        statLeadingGamesCount.setText(Integer.toString(leadingGamesCount));
        statSuccessfulGamesCount.setText(
                Integer.toString(successfulLeadingGamesCount) + " (" + Integer.toString(successRate) + "%)");

        // display called game count if necessary 
        if (this.getGameSet().getGameStyleType() == GameStyleType.Tarot5) {
            TextView statCalledGamesCount = (TextView) statRow.findViewById(R.id.statCalledGamesCount);
            statCalledGamesCount
                    .setText(Integer.toString(calledCount.get(player) == null ? 0 : calledCount.get(player)));
        }

        statMinScore.setText(Integer.toString(minScoreForPlayer));
        statMaxScore.setText(Integer.toString(maxScoreForPlayer));
        statMinScore.setTextColor(Color.WHITE);
        statMaxScore.setTextColor(Color.WHITE);

        // color min score if lowest
        if (minScoreEver == minScoreForPlayer) {
            statMinScore.setTextColor(Color.YELLOW);
        }

        // color max score if highest
        if (maxScoreEver == maxScoreForPlayer) {
            statMaxScore.setTextColor(Color.GREEN);
        }
    }
}

From source file:edu.cens.loci.ui.widget.GenericEditorView.java

private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) {

    ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>();

    HashMap<String, APInfoMapItem> apMap = wifi.getAps();
    Set<String> keys = apMap.keySet();
    Iterator<String> iter = keys.iterator();
    while (iter.hasNext()) {
        String bssid = iter.next();
        APInfoMapItem ap = apMap.get(bssid);
        items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets));
    }/* ww w. ja v a 2  s .c  o m*/

    Collections.sort(items);

    table.setColumnCollapsed(0, false);
    table.setColumnCollapsed(1, true);
    table.setColumnShrinkable(0, true);

    for (int i = 0; i < mAddedRows.size(); i++) {
        table.removeView(mAddedRows.get(i));
    }
    mAddedRows.clear();

    int totalCount = wifi.getScanCount();

    Context context = getContext();

    for (WifiViewListItem item : items) {
        TableRow row = new TableRow(context);

        TextView ssidView = new TextView(context);
        ssidView.setText(item.ssid);
        //ssidView.setText("very very very veryvery very very very very very");
        ssidView.setPadding(2, 2, 2, 2);
        ssidView.setTextColor(0xffffffff);

        TextView bssidView = new TextView(context);
        bssidView.setText(item.bssid);
        bssidView.setPadding(2, 2, 2, 2);
        bssidView.setTextColor(0xffffffff);

        TextView cntView = new TextView(context);
        cntView.setText("" + (item.count * 100) / totalCount);
        cntView.setPadding(2, 2, 2, 2);
        cntView.setGravity(Gravity.CENTER);
        cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        TextView rssView = new TextView(context);
        rssView.setText("" + item.rss);
        rssView.setPadding(2, 2, 6, 2);
        rssView.setGravity(Gravity.CENTER);
        rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);

        row.addView(ssidView, new TableRow.LayoutParams(0));
        row.addView(bssidView, new TableRow.LayoutParams(1));
        row.addView(cntView, new TableRow.LayoutParams(2));
        row.addView(rssView, new TableRow.LayoutParams(3));

        //Log.d(TAG, item.ssid);
        for (int i = 0; i < item.rssBuckets.length; i++) {
            TextView box = new TextView(context);
            box.setText("  ");
            box.setGravity(Gravity.RIGHT);
            box.setPadding(2, 2, 2, 2);
            box.setHeight(15);
            box.setGravity(Gravity.CENTER_VERTICAL);

            float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount());
            //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]);
            int colorValInt = ((int) colorVal) - 1;
            if (colorValInt < 0)
                colorValInt = 0;

            box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan));
            box.setTextColor(0xffffffff);

            row.addView(box, new TableRow.LayoutParams(4 + i));
        }

        row.setGravity(Gravity.CENTER);

        table.addView(row, new TableLayout.LayoutParams());
        table.setColumnStretchable(3, true);
        mAddedRows.add(row);
    }

}