Example usage for android.widget TextView setSingleLine

List of usage examples for android.widget TextView setSingleLine

Introduction

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

Prototype

@android.view.RemotableViewMethod
public void setSingleLine(boolean singleLine) 

Source Link

Document

If true, sets the properties of this field (number of lines, horizontally scrolling, transformation method) to be for a single-line input; if false, restores these to the default conditions.

Usage

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

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private TextView makeTextView(String value, int color, int horizontalPadding) {
    Context context = getActivity();
    TextView textView = new TextView(context);
    textView.setText(value);/*  w w w  . ja  v  a2s.  c om*/
    textView.setLayoutParams(
            new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT));
    textView.setTextAppearance(context, android.R.attr.textAppearanceSmall);
    textView.setTextColor(color);
    textView.setPadding(horizontalPadding, 0, horizontalPadding, 0);
    textView.setSingleLine(false);
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
        textView.setTextIsSelectable(true);
    }
    return textView;
}

From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java

private void handleStation(@NonNull final FavoritesViewHolder holder, @NonNull final Station station) {
    final int stationId = station.getId();
    final Set<TrainLine> trainLines = station.getLines();

    holder.favoriteImage.setImageResource(R.drawable.ic_train_white_24dp);
    holder.stationNameTextView.setText(station.getName());
    holder.detailsButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {/* w  ww  . j av  a 2s. c o m*/
            // Start station activity
            final Bundle extras = new Bundle();
            final Intent intent = new Intent(context, StationActivity.class);
            extras.putInt(activity.getString(R.string.bundle_train_stationId), stationId);
            intent.putExtras(extras);
            activity.startActivity(intent);
        }
    });

    holder.mapButton.setText(activity.getString(R.string.favorites_view_trains));
    holder.mapButton.setOnClickListener(v -> {
        if (!Util.isNetworkAvailable(context)) {
            Util.showNetworkErrorMessage(activity);
        } else {
            if (trainLines.size() == 1) {
                startActivity(trainLines.iterator().next());
            } else {
                final List<Integer> colors = new ArrayList<>();
                final List<String> values = Stream.of(trainLines).flatMap(line -> {
                    final int color = line != TrainLine.YELLOW ? line.getColor()
                            : ContextCompat.getColor(context, R.color.yellowLine);
                    colors.add(color);
                    return Stream.of(line.toStringWithLine());
                }).collect(Collectors.toList());

                final PopupFavoritesTrainAdapter ada = new PopupFavoritesTrainAdapter(activity, values, colors);

                final List<TrainLine> lines = new ArrayList<>();
                lines.addAll(trainLines);

                final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                builder.setAdapter(ada, (dialog, position) -> startActivity(lines.get(position)));

                final int[] screenSize = Util.getScreenSize(context);
                final AlertDialog dialog = builder.create();
                dialog.show();
                if (dialog.getWindow() != null) {
                    dialog.getWindow().setLayout((int) (screenSize[0] * 0.7), LayoutParams.WRAP_CONTENT);
                }
            }
        }
    });

    Stream.of(trainLines).forEach(trainLine -> {
        boolean newLine = true;
        int i = 0;
        final Map<String, StringBuilder> etas = favoritesData.getTrainArrivalByLine(stationId, trainLine);
        for (final Entry<String, StringBuilder> entry : etas.entrySet()) {
            final LinearLayout.LayoutParams containParam = getInsideParams(newLine, i == etas.size() - 1);
            final LinearLayout container = new LinearLayout(context);
            container.setOrientation(LinearLayout.HORIZONTAL);
            container.setLayoutParams(containParam);

            // Left
            final RelativeLayout.LayoutParams leftParam = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            final RelativeLayout left = new RelativeLayout(context);
            left.setLayoutParams(leftParam);

            final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, trainLine);
            int lineId = Util.generateViewId();
            lineIndication.setId(lineId);

            final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId);
            destinationParams.setMargins(pixelsHalf, 0, 0, 0);

            final String destination = entry.getKey();
            final TextView destinationTextView = new TextView(context);
            destinationTextView.setTextColor(grey5);
            destinationTextView.setText(destination);
            destinationTextView.setLines(1);
            destinationTextView.setLayoutParams(destinationParams);

            left.addView(lineIndication);
            left.addView(destinationTextView);

            // Right
            final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            rightParams.setMargins(marginLeftPixel, 0, 0, 0);
            final LinearLayout right = new LinearLayout(context);
            right.setOrientation(LinearLayout.VERTICAL);
            right.setLayoutParams(rightParams);

            final StringBuilder currentEtas = entry.getValue();
            final TextView arrivalText = new TextView(context);
            arrivalText.setText(currentEtas);
            arrivalText.setGravity(Gravity.END);
            arrivalText.setSingleLine(true);
            arrivalText.setTextColor(grey5);
            arrivalText.setEllipsize(TextUtils.TruncateAt.END);

            right.addView(arrivalText);

            container.addView(left);
            container.addView(right);

            holder.mainLayout.addView(container);

            newLine = false;
            i++;
        }
    });
}

From source file:com.thelastcrusade.soundstream.util.MusicListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View element = convertView;/*from ww  w  . ja  v  a  2s  .  com*/

    if (element == null) {
        LayoutInflater inflater = (LayoutInflater) this.mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        element = inflater.inflate(R.layout.song_item, null);
    }

    View userColor = (View) element.findViewById(R.id.user_color);
    TextView title = (TextView) element.findViewById(R.id.title);
    TextView album = (TextView) element.findViewById(R.id.album);
    TextView artist = (TextView) element.findViewById(R.id.artist);
    ImageButton addButton = (ImageButton) element.findViewById(R.id.btn_add_to_playlist);

    String macAddress = metadataList.get(position).getMacAddress();

    User user = users.getUserByMACAddress(macAddress);
    if (user != null) {
        userColor.setBackgroundColor(user.getColor());
    } else {
        Log.wtf(TAG, "User with mac address " + macAddress + " not found.  Using default color.");
        userColor.setBackgroundColor(mContext.getResources().getColor(R.color.transparent));
    }

    //set the default sizes
    userColor.setMinimumHeight((int) mContext.getResources().getDimension(R.dimen.song_height));
    title.setSingleLine(true);
    artist.setSingleLine(true);
    album.setSingleLine(true);

    addButton.setTag(position);
    addButton.setContentDescription(
            ContentDescriptionUtils.addToPlaylistAppendSongTitle(metadataList.get(position)));

    title.setText(metadataList.get(position).getTitle());
    artist.setText(metadataList.get(position).getArtist());
    album.setText(metadataList.get(position).getAlbum());

    artist.setMaxWidth(parent.getWidth() / 2);
    /*
    final GestureDetectorCompat songGesture = new GestureDetectorCompat(mContext, new SongGestureListener(element));
    element.setOnTouchListener(new View.OnTouchListener() {       
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      return songGesture.onTouchEvent(event);
    }
    });*/
    return element;
}

From source file:nl.openkvk.MainActivity.java

public void searchInKvK(View view) {
    TableLayout tl = (TableLayout) findViewById(R.id.tableOuter);
    tl.removeAllViews();//from w w w.j  a  v  a  2s .  c  o m
    EditText _naam = (EditText) findViewById(R.id.inpNaam);
    EditText _straat = (EditText) findViewById(R.id.inpStraat);
    EditText _postcode = (EditText) findViewById(R.id.inpPostcode);
    EditText _plaats = (EditText) findViewById(R.id.inpPlaats);
    EditText _hdlNaam = (EditText) findViewById(R.id.inpHandelsNaam);
    String naam = _naam.getText().toString().trim();
    String hdlNaam = _hdlNaam.getText().toString().trim();
    String straat = _straat.getText().toString().trim();
    String postcode = _postcode.getText().toString().trim().toUpperCase();
    if (postcode.indexOf(' ') > 0) {
        postcode = postcode.replace(" ", "");
    }
    String plaats = _plaats.getText().toString().trim();
    _naam.setText(naam);
    _hdlNaam.setText(hdlNaam);
    _straat.setText(straat);
    _postcode.setText(postcode);
    _plaats.setText(plaats);
    String sql = null;
    if (naam.length() > 0) {
        try {
            Integer kvk = Integer.valueOf(naam);
            sql = "/json/select * from kvk where kvks=" + kvk;
        } catch (Exception ignore) {
            sql = "/json/select * from kvk where bedrijfsnaam ilike '" + naam + "%'";
        }
        if (straat.length() > 0) {
            sql += " and adres ilike '" + straat + "%'";
        }
        if (plaats.length() > 0) {
            sql += " and plaats ilike '" + plaats + "%'";
        }
        if (postcode.length() > 0) {
            sql += " and postcode ilike '" + postcode + "%'";
        }
        sql += " LIMIT 1000;";
    } else if (hdlNaam.length() > 0) {
        sql = "/json/select * from kvk,kvk_handelsnamen where kvk.kvks=kvk_handelsnamen.kvks and handelsnaam ilike '"
                + hdlNaam + "%'";
        sql += " LIMIT 1000;";
    } else if (straat.length() > 0 && (plaats.length() > 0 || postcode.length() > 0)) {
        sql = "/json/select * from kvk where adres ilike '" + straat + "%'";
        if (plaats.length() > 0) {
            sql += " and plaats ilike '" + plaats + "%'";
        }
        if (postcode.length() > 0) {
            sql += " and postcode ilike '" + postcode + "%'";
        }
        sql += " LIMIT 1000;";
    } else if (postcode.length() == 6) {
        sql = "/json/select * from kvk where postcode='" + postcode + "'";
        sql += " LIMIT 1000;";
    }
    if (sql != null) {
        TextView tv = new TextView(this);
        tv.setText("Even geduld AUB...");
        TableRow tr = new TableRow(this);
        tr.addView(tv);
        tl.addView(tr);
        new Caller(handler, handler.holder, sql, 2).start();
    } else {
        {
            TextView tv = new TextView(this);
            tv.setText("Ongeldige invoer.");
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Geef een (gedeelte van) een bedrijfsnaam in. Of geef het KvK nummer.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Geef eventueel ook (het begin van) een straat, postcode en/of plaatsnaam in.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Of geef een straat (mag met huisnummer) en een plaats en/of een postcode in.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Of geef alleen een volledige postcode in.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
    }
}

From source file:com.sentaroh.android.TextFileBrowser.ViewedFileListAdapter.java

@SuppressWarnings("deprecation")
@Override/*from   w  w w.j a  v  a 2 s .c om*/
public View getDropDownView(int position, View convertView, ViewGroup parent) {
    final TextView text = (TextView) super.getDropDownView(position, convertView, parent);
    //        text.setBackgroundColor(Color.LTGRAY);
    if (Build.VERSION.SDK_INT >= 11) {
        //          text.setCompoundDrawablePadding(10);
        //          text.setCompoundDrawablesWithIntrinsicBounds(
        //                mContext.getResources().getDrawable(android.R.drawable.btn_radio), 
        //                null, null, null);
        text.setCompoundDrawablesWithIntrinsicBounds(null, null,
                mContext.getResources().getDrawable(android.R.drawable.btn_radio), null);

    }
    text.setText(getItem(position).file_path);
    //       text.setEllipsize(TruncateAt.START);
    text.post(new Runnable() {
        @Override
        public void run() {
            text.setSingleLine(false);
        }
    });

    //        text.setTextColor(Color.BLACK);
    //        if (text_color!=0) text.setTextColor(text_color);
    //        if (text_size!=0) text.setTextSize(text_size);

    return text;
}

From source file:com.b44t.ui.ActionBar.BottomSheet.java

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

    Window window = getWindow();/*from   www .  j  av  a  2  s  . co  m*/
    window.setWindowAnimations(R.style.DialogNoAnimation);
    setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (containerView == null) {
        containerView = new FrameLayout(getContext()) {
            @Override
            public boolean hasOverlappingRendering() {
                return false;
            }
        };
        containerView.setBackgroundDrawable(shadowDrawable);
        containerView.setPadding(backgroundPaddingLeft,
                (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft,
                (applyBottomPadding ? AndroidUtilities.dp(8) : 0));
    }
    if (Build.VERSION.SDK_INT >= 21) {
        containerView.setFitsSystemWindows(true);
    }
    containerView.setVisibility(View.INVISIBLE);
    container.addView(containerView, 0,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));

    if (customView != null) {
        if (customView.getParent() != null) {
            ViewGroup viewGroup = (ViewGroup) customView.getParent();
            viewGroup.removeView(customView);
        }
        containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
    } else {
        int topOffset = 0;
        if (title != null) {
            TextView titleView = new TextView(getContext());
            titleView.setLines(1);
            titleView.setSingleLine(true);
            titleView.setText(title);
            titleView.setTextColor(0xff757575);
            titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
            titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
            titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8));
            titleView.setGravity(Gravity.CENTER_VERTICAL);
            containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48));
            titleView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });
            topOffset += 48;
        }
        if (items != null) {
            FrameLayout rowLayout = null;
            int lastRowLayoutNum = 0;
            for (int a = 0; a < items.length; a++) {
                BottomSheetCell cell = new BottomSheetCell(getContext(), 0);
                cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0);
                containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48,
                        Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0));
                topOffset += 48;
                cell.setTag(a);
                cell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dismissWithButtonClick((Integer) v.getTag());
                    }
                });
                itemViews.add(cell);
            }
        }
    }

    WindowManager.LayoutParams params = window.getAttributes();
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.dimAmount = 0;
    params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    if (!focusable) {
        params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    }
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
    window.setAttributes(params);
}

From source file:kr.wdream.ui.ActionBar.BottomSheet.java

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

    Window window = getWindow();//from   www  .  java  2  s .  com
    window.setWindowAnimations(kr.wdream.storyshop.R.style.DialogNoAnimation);
    setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (containerView == null) {
        containerView = new FrameLayout(getContext()) {
            @Override
            public boolean hasOverlappingRendering() {
                return false;
            }
        };
        containerView.setBackgroundDrawable(shadowDrawable);
        containerView.setPadding(backgroundPaddingLeft,
                (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft,
                (applyBottomPadding ? AndroidUtilities.dp(8) : 0));
    }
    if (Build.VERSION.SDK_INT >= 21) {
        containerView.setFitsSystemWindows(true);
    }
    containerView.setVisibility(View.INVISIBLE);
    container.addView(containerView, 0,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));

    if (customView != null) {
        if (customView.getParent() != null) {
            ViewGroup viewGroup = (ViewGroup) customView.getParent();
            viewGroup.removeView(customView);
        }
        containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
    } else {
        int topOffset = 0;
        if (title != null) {
            TextView titleView = new TextView(getContext());
            titleView.setLines(1);
            titleView.setSingleLine(true);
            titleView.setText(title);
            titleView.setTextColor(0xff757575);
            titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
            titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
            titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8));
            titleView.setGravity(Gravity.CENTER_VERTICAL);
            containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48));
            titleView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });
            topOffset += 48;
        }
        if (items != null) {
            FrameLayout rowLayout = null;
            int lastRowLayoutNum = 0;
            for (int a = 0; a < items.length; a++) {
                BottomSheetCell cell = new BottomSheetCell(getContext(), 0);
                cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0);
                containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48,
                        Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0));
                topOffset += 48;
                cell.setTag(a);
                cell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dismissWithButtonClick((Integer) v.getTag());
                    }
                });
                itemViews.add(cell);
            }
        }
    }

    WindowManager.LayoutParams params = window.getAttributes();
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.dimAmount = 0;
    params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    if (!focusable) {
        params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    }
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
    window.setAttributes(params);
}

From source file:com.cssweb.android.quote.QHSCGridActivity.java

private void AddViewItem(int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3,
        int paramInt4, boolean paramBoolean) {
    TextView localTextView = new TextView(this);
    float f = this.mFontSize;
    localTextView.setTextSize(f);/*from  www .  j  a v a 2 s  . c  o  m*/

    localTextView.setGravity(Gravity.CENTER);
    localTextView.setFocusable(paramBoolean);
    localTextView.setOnClickListener(mClickListener);
    localTextView.setOnLongClickListener(mLongClickListener);
    localTextView.setOnTouchListener(this); // touch
    localTextView.setTag(paramInt2);
    localTextView.setEnabled(paramBoolean);
    localTextView.setSingleLine(true);
    Resources localResources = getResources();
    Drawable localDrawable = null;
    if (paramInt4 == 0 && paramInt3 >= 0) {// 
        int i1 = this.residTitleCol;
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(i1);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[2]);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[1]);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residTitleScrollCol[0]);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this));
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
    if (paramInt4 != 0 && paramInt3 >= 0) {
        int i8 = 0;
        localTextView.setTextColor(paramInt1);
        if (paramInt3 == 0) {
            localDrawable = localResources.getDrawable(this.residCol);
            i8 = localDrawable.getIntrinsicWidth();
        } else if (paramInt3 == 100) {
            localDrawable = localResources.getDrawable(this.residScrollCol[2]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
            i8 += 20;
        } else if (paramInt3 == 13) {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();

        } else if (paramInt3 % 2 == 0) {
            localDrawable = localResources.getDrawable(this.residScrollCol[1]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        } else {
            localDrawable = localResources.getDrawable(this.residScrollCol[0]);
            localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
            i8 = localDrawable.getIntrinsicWidth();
        }
        localTextView.setBackgroundDrawable(localDrawable);
        int i6 = localDrawable.getIntrinsicHeight();
        localTextView.setHeight(i6 + rowHeight);
        localTextView.setWidth(i8);
        paramLinearLayout.addView(localTextView);
        return;
    }
}

From source file:com.example.drugsformarinemammals.Dose_Information.java

public void show_dose(ArrayList<Dose_Data> dose, TableLayout dose_table, TableRow dose_data, String drug_name,
        String group_name, String animal_family, String animal_name, String animal_category,
        ArrayList<String> notes, ArrayList<String> references, ArrayList<Article_Reference> references_index) {

    String doseAmount;/*from   w  ww.j ava2  s  .  c o m*/
    String dosePosology;
    String doseRoute;
    String doseBookReference;
    String doseArticleReference;
    for (int k = 0; k < dose.size(); k++) {
        if (k > 0) {
            dose_data = new TableRow(this);
        }

        doseAmount = dose.get(k).getAmount();
        dosePosology = dose.get(k).getPosology();
        doseRoute = dose.get(k).getRoute();
        doseBookReference = dose.get(k).getBookReference();
        doseArticleReference = dose.get(k).getArticleReference();

        //Dose amount data

        TextView textView_animal_dose_amount = new TextView(this);
        textView_animal_dose_amount.setText(doseAmount);
        textView_animal_dose_amount.setSingleLine(false);
        textView_animal_dose_amount.setTextColor(Color.BLACK);
        textView_animal_dose_amount.setTextSize(15);
        textView_animal_dose_amount.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDoseAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDoseAmount.gravity = Gravity.CENTER;
        dose_data.addView(textView_animal_dose_amount, paramsDoseAmount);

        //Dose posology data

        TextView textView_animal_dose_posology = new TextView(this);
        textView_animal_dose_posology.setText(dosePosology);
        textView_animal_dose_posology.setSingleLine(false);
        textView_animal_dose_posology.setTextColor(Color.BLACK);
        textView_animal_dose_posology.setTextSize(15);
        textView_animal_dose_posology.setTypeface(Typeface.SANS_SERIF);
        TableRow.LayoutParams paramsDosePosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                TableRow.LayoutParams.WRAP_CONTENT);
        paramsDosePosology.gravity = Gravity.CENTER;
        if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Posology"))
                || screenWidth >= 600)
            dose_data.addView(textView_animal_dose_posology, paramsDosePosology);

        //Dose route data

        TextView textView_animal_dose_route = new TextView(this);
        textView_animal_dose_route.setText(doseRoute);
        textView_animal_dose_route.setSingleLine(false);
        textView_animal_dose_route.setTextColor(Color.BLACK);
        textView_animal_dose_route.setTextSize(15);
        textView_animal_dose_route.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        } else {
            TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(30,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseRoute.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_route, paramsDoseRoute);
        }

        //Dose reference data

        TextView textView_animal_dose_reference = new TextView(this);
        if (!doseBookReference.equals(""))
            textView_animal_dose_reference.setText(doseBookReference);
        else if (!doseArticleReference.equals("")) {
            if (!references.contains(doseArticleReference)) {
                references.add(references.size(), doseArticleReference);
                Article_Reference article_reference = new Article_Reference(reference_index,
                        doseArticleReference);
                references_index.add(references_index.size(), article_reference);
                reference_index++;
            }
            int article_index = references.indexOf(doseArticleReference);
            textView_animal_dose_reference.setText("(" + references_index.get(article_index).getIndex() + ")");
        }
        textView_animal_dose_reference.setSingleLine(false);
        textView_animal_dose_reference.setTextColor(Color.BLACK);
        textView_animal_dose_reference.setTextSize(15);
        textView_animal_dose_reference.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600) {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        } else {
            TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsDoseReference.gravity = Gravity.CENTER;
            dose_data.addView(textView_animal_dose_reference, paramsDoseReference);
        }

        //Specific note index

        ArrayList<String> specific_notes = new ArrayList<String>();
        specific_notes = helper.read_specific_notes(drug_name, group_name, animal_name, animal_family,
                animal_category, doseAmount, dosePosology, doseRoute, doseBookReference, doseArticleReference);

        String index = "";
        for (int m = 0; m < specific_notes.size(); m++) {
            String note = specific_notes.get(m);
            if (!notes.contains(note)) {
                notes.add(notes.size(), note);
            }
            index += "(" + (notes.indexOf(note) + 1) + ")  ";
        }

        TextView textView_specific_note_index = new TextView(this);
        textView_specific_note_index.setText(index);
        textView_specific_note_index.setSingleLine(false);
        textView_specific_note_index.setTextColor(Color.BLACK);
        textView_specific_note_index.setTextSize(15);
        textView_specific_note_index.setTypeface(Typeface.SANS_SERIF);
        if (screenWidth >= 600 && screenWidth < 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(150,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else if (screenWidth >= 720) {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        } else {
            TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(100,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNoteIndex.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Note"))
                    || screenWidth >= 600)
                dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex);
        }

        dose_table.addView(dose_data);

    }
}

From source file:ir.besteveryeverapp.ui.ActionBar.BottomSheet.java

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

    Window window = getWindow();/*ww w  . j  a va 2  s  . com*/
    window.setWindowAnimations(R.style.DialogNoAnimation);
    setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    if (containerView == null) {
        containerView = new FrameLayout(getContext()) {
            @Override
            public boolean hasOverlappingRendering() {
                return false;
            }
        };
        containerView.setBackgroundDrawable(shadowDrawable);
        containerView.setPadding(backgroundPaddingLeft,
                (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft,
                (applyBottomPadding ? AndroidUtilities.dp(8) : 0));
    }
    if (Build.VERSION.SDK_INT >= 21) {
        containerView.setFitsSystemWindows(true);
    }
    containerView.setVisibility(View.INVISIBLE);
    container.addView(containerView, 0,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));

    if (customView != null) {
        if (customView.getParent() != null) {
            ViewGroup viewGroup = (ViewGroup) customView.getParent();
            viewGroup.removeView(customView);
        }
        containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
                LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
    } else {
        int topOffset = 0;
        if (title != null) {
            TextView titleView = new TextView(getContext());
            titleView.setTypeface(FontManager.instance().getTypeface());
            titleView.setLines(1);
            titleView.setSingleLine(true);
            titleView.setText(title);
            titleView.setTextColor(0xff757575);
            titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
            titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE);
            titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8));
            titleView.setGravity(Gravity.CENTER_VERTICAL);
            containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48));
            titleView.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });
            topOffset += 48;
        }
        if (items != null) {
            FrameLayout rowLayout = null;
            int lastRowLayoutNum = 0;
            for (int a = 0; a < items.length; a++) {
                BottomSheetCell cell = new BottomSheetCell(getContext(), 0);
                cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0);
                containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48,
                        Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0));
                topOffset += 48;
                cell.setTag(a);
                cell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dismissWithButtonClick((Integer) v.getTag());
                    }
                });
                itemViews.add(cell);
            }
        }
    }

    WindowManager.LayoutParams params = window.getAttributes();
    params.width = ViewGroup.LayoutParams.MATCH_PARENT;
    params.gravity = Gravity.TOP | Gravity.LEFT;
    params.dimAmount = 0;
    params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    if (!focusable) {
        params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    }
    params.height = ViewGroup.LayoutParams.MATCH_PARENT;
    window.setAttributes(params);
}