Example usage for android.graphics Typeface SANS_SERIF

List of usage examples for android.graphics Typeface SANS_SERIF

Introduction

In this page you can find the example usage for android.graphics Typeface SANS_SERIF.

Prototype

Typeface SANS_SERIF

To view the source code for android.graphics Typeface SANS_SERIF.

Click Source Link

Document

The NORMAL style of the default sans serif typeface.

Usage

From source file:com.anjalimacwan.adapter.NoteListDateAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    NoteListItem item = getItem(position);
    String note = item.getNote();
    String date = item.getDate();

    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null)
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout_date, parent, false);

    // Lookup view for data population
    TextView noteTitle = (TextView) convertView.findViewById(R.id.noteTitle);
    TextView noteDate = (TextView) convertView.findViewById(R.id.noteDate);

    // Populate the data into the template view using the data object
    noteTitle.setText(note);/* ww w.  j av a  2s .co m*/
    noteDate.setText(date);

    // Apply theme
    SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences",
            Context.MODE_PRIVATE);
    String theme = pref.getString("theme", "light-sans");

    if (theme.contains("light")) {
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary));
        noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary));
    }

    if (theme.contains("dark")) {
        noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark));
        noteDate.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_secondary_dark));
    }

    if (theme.contains("sans")) {
        noteTitle.setTypeface(Typeface.SANS_SERIF);
        noteDate.setTypeface(Typeface.SANS_SERIF);
    }

    if (theme.contains("serif")) {
        noteTitle.setTypeface(Typeface.SERIF);
        noteDate.setTypeface(Typeface.SERIF);
    }

    if (theme.contains("monospace")) {
        noteTitle.setTypeface(Typeface.MONOSPACE);
        noteDate.setTypeface(Typeface.MONOSPACE);
    }

    switch (pref.getString("font_size", "normal")) {
    case "smallest":
        noteTitle.setTextSize(12);
        noteDate.setTextSize(8);
        break;
    case "small":
        noteTitle.setTextSize(14);
        noteDate.setTextSize(10);
        break;
    case "normal":
        noteTitle.setTextSize(16);
        noteDate.setTextSize(12);
        break;
    case "large":
        noteTitle.setTextSize(18);
        noteDate.setTextSize(14);
        break;
    case "largest":
        noteTitle.setTextSize(20);
        noteDate.setTextSize(16);
        break;
    }

    // Return the completed view to render on screen
    return convertView;
}

From source file:de.treichels.hott.ui.android.html.AndroidCurveImageGenerator.java

private Bitmap getBitmap(final Curve curve, final float scale, final boolean description) {
    final boolean pitchCurve = curve.getPoint()[0].getPosition() == 0;
    final float scale1 = scale * 0.75f; // smaller images on the android
    // platform//from   ww  w .  java  2 s.  c o m

    final Bitmap image = Bitmap.createBitmap((int) (10 + 200 * scale1), (int) (10 + 250 * scale1),
            Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(image);

    final Paint backgroundPaint = new Paint();
    backgroundPaint.setColor(Color.WHITE);
    backgroundPaint.setStyle(Style.FILL);

    final Paint forgroundPaint = new Paint();
    forgroundPaint.setColor(Color.BLACK);
    forgroundPaint.setStyle(Style.STROKE);
    forgroundPaint.setStrokeWidth(1.0f);
    forgroundPaint.setStrokeCap(Cap.BUTT);
    forgroundPaint.setStrokeJoin(Join.ROUND);
    forgroundPaint.setStrokeMiter(0.0f);

    final Paint curvePaint = new Paint(forgroundPaint);
    curvePaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    curvePaint.setStrokeWidth(2.0f);

    final Paint pointPaint = new Paint(curvePaint);
    pointPaint.setStrokeWidth(5.0f);
    pointPaint.setStyle(Style.FILL_AND_STROKE);

    final Paint helpLinePaint = new Paint(forgroundPaint);
    helpLinePaint.setColor(Color.GRAY);
    helpLinePaint.setPathEffect(new DashPathEffect(new float[] { 5.0f, 5.0f }, 2.5f));

    final Paint textPaint = new Paint(forgroundPaint);
    textPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
    textPaint.setTextSize(12.0f);
    textPaint.setTextAlign(Align.CENTER);
    textPaint.setStyle(Style.FILL);

    canvas.drawRect(0, 0, 10 + 200 * scale1, 10 + 250 * scale1, backgroundPaint);
    canvas.drawRect(5, 5, 5 + 200 * scale1, 5 + 250 * scale1, forgroundPaint);

    canvas.drawLine(5, 5 + 25 * scale1, 5 + 200 * scale1, 5 + 25 * scale1, helpLinePaint);
    canvas.drawLine(5, 5 + 225 * scale1, 5 + 200 * scale1, 5 + 225 * scale1, helpLinePaint);
    if (!pitchCurve) {
        canvas.drawLine(5, 5 + 125 * scale1, 5 + 200 * scale1, 5 + 125 * scale1, helpLinePaint);
        canvas.drawLine(5 + 100 * scale1, 5, 5 + 100 * scale1, 5 + 250 * scale1, helpLinePaint);
    }

    if (curve.getPoint() != null) {
        int numPoints = 0;
        for (final CurvePoint p : curve.getPoint()) {
            if (p.isEnabled()) {
                numPoints++;
            }
        }

        final double[] xVals = new double[numPoints];
        final double[] yVals = new double[numPoints];

        int i = 0;
        for (final CurvePoint p : curve.getPoint()) {
            if (p.isEnabled()) {
                if (i == 0) {
                    xVals[i] = pitchCurve ? 0 : -100;
                } else if (i == numPoints - 1) {
                    xVals[i] = 100;
                } else {
                    xVals[i] = p.getPosition();
                }
                yVals[i] = p.getValue();

                if (description) {
                    float x0;
                    float y0;
                    if (pitchCurve) {
                        x0 = (float) (5 + xVals[i] * 2 * scale1);
                        y0 = (float) (5 + (225 - yVals[i] * 2) * scale1);
                    } else {
                        x0 = (float) (5 + (100 + xVals[i]) * scale1);
                        y0 = (float) (5 + (125 - yVals[i]) * scale1);
                    }

                    canvas.drawPoint(x0, y0, pointPaint);
                    if (y0 < 5 + 125 * scale1) {
                        canvas.drawRect(x0 - 4, y0 + 5, x0 + 3, y0 + 18, backgroundPaint);
                        canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 + 16, textPaint);
                    } else {
                        canvas.drawRect(x0 - 4, y0 - 5, x0 + 3, y0 - 18, backgroundPaint);
                        canvas.drawText(Integer.toString(p.getNumber() + 1), x0 - 1, y0 - 7, textPaint);
                    }
                }

                i++;
            }
        }

        if (numPoints > 2 && curve.isSmoothing()) {
            final SplineInterpolator s = new SplineInterpolator();
            final PolynomialSplineFunction function = s.interpolate(xVals, yVals);

            float x0 = 5;
            float y0;
            if (pitchCurve) {
                y0 = (float) (5 + (225 - yVals[0] * 2) * scale1);
            } else {
                y0 = (float) (5 + (125 - yVals[0]) * scale1);
            }

            while (x0 < 4 + 200 * scale1) {
                final float x1 = x0 + 1;
                float y1;
                if (pitchCurve) {
                    y1 = (float) (5 + (225 - function.value((x1 - 5) / scale1 / 2) * 2) * scale1);
                } else {
                    y1 = (float) (5 + (125 - function.value((x1 - 5) / scale1 - 100)) * scale1);
                }

                canvas.drawLine(x0, y0, x1, y1, curvePaint);

                x0 = x1;
                y0 = y1;
            }
        } else {
            for (i = 0; i < numPoints - 1; i++) {
                float x0, y0, x1, y1;

                if (pitchCurve) {
                    x0 = (float) (5 + xVals[i] * 2 * scale1);
                    y0 = (float) (5 + (225 - yVals[i] * 2) * scale1);

                    x1 = (float) (5 + xVals[i + 1] * 2 * scale1);
                    y1 = (float) (5 + (225 - yVals[i + 1] * 2) * scale1);
                } else {
                    x0 = (float) (5 + (100 + xVals[i]) * scale1);
                    y0 = (float) (5 + (125 - yVals[i]) * scale1);

                    x1 = (float) (5 + (100 + xVals[i + 1]) * scale1);
                    y1 = (float) (5 + (125 - yVals[i + 1]) * scale1);
                }

                canvas.drawLine(x0, y0, x1, y1, curvePaint);
            }
        }
    }

    return image;
}

From source file:com.google.samples.apps.iosched.util.LPreviewUtilsBase.java

public void setMediumTypeface(TextView textView) {
    textView.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
}

From source file:com.jauker.badgeview.example.ViewsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.fragment_views, null);

    View backgroundDefaultView = layout.findViewById(R.id.backgroundDefault);
    backgroundDefaultBadge = new BadgeView(getActivity());
    backgroundDefaultBadge.setBadgeCount(42);
    backgroundDefaultBadge.setTargetView(backgroundDefaultView);

    View backgroundDrawableView = layout.findViewById(R.id.backgroundDrawable);
    backgroundDrawableBadge = new BadgeView(getActivity());
    backgroundDrawableBadge.setBadgeCount(88);
    backgroundDrawableBadge.setBackgroundResource(R.drawable.badge_blue);
    backgroundDrawableBadge.setTargetView(backgroundDrawableView);

    View backgroundShapeView = layout.findViewById(R.id.backgroundShape);
    backgroundShapeBadge = new BadgeView(getActivity());
    backgroundShapeBadge.setBadgeCount(47);
    backgroundShapeBadge.setBackground(12, Color.parseColor("#9b2eef"));
    backgroundShapeBadge.setTargetView(backgroundShapeView);

    View counterView = layout.findViewById(R.id.counter);
    counterView.setOnClickListener(this);
    counterBadge = new BadgeView(getActivity());
    counterBadge.setBadgeCount(-2);/*ww  w  .j a v  a  2 s . c o m*/
    counterBadge.setTargetView(counterView);

    View gravityView = layout.findViewById(R.id.gravity);
    gravityView.setOnClickListener(this);
    gravityBadge = new BadgeView(getActivity());
    gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM);
    gravityBadge.setBadgeCount(4);
    gravityBadge.setTargetView(gravityView);

    View textStyleView = layout.findViewById(R.id.textStyle);
    textStyleView.setOnClickListener(this);
    textStyleBadge = new BadgeView(getActivity());
    textStyleBadge.setBadgeCount(18);
    textStyleBadge.setTargetView(textStyleView);
    textStyleBadge.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));
    textStyleBadge.setShadowLayer(2, -1, -1, Color.GREEN);

    View visibilityView = layout.findViewById(R.id.visibility);
    visibilityView.setOnClickListener(this);
    visibilityBadgeView = new BadgeView(getActivity());
    visibilityBadgeView.setBadgeCount(1);
    visibilityBadgeView.setTargetView(visibilityView);

    return layout;
}

From source file:pt.hive.cameo.activities.LoginActivity.java

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

    // saves a reference to the current instance under the self variable
    // so that it may be used by any clojure method
    final LoginActivity self = this;

    // tries to retrieve the extras set of parameters from the intent
    // and in case they exist, tries to retrieve the login path (parameter)
    Bundle extras = this.getIntent().getExtras();
    if (extras != null) {
        this.loginPath = extras.getString("LOGIN_PATH");
        this.logoId = extras.getInt("LOGO_ID");
    }/*from ww w .j av a2 s  . co m*/

    // removes the title bar from the window (improves readability)
    // and then sets the login layout on it (starts the layout)
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.setContentView(R.layout.login);

    // in case we've received a valid logo identifier the logo image must be
    // updated with the associated resource (customized view)
    if (this.logoId != 0) {
        Drawable logoResource = this.getResources().getDrawable(this.logoId);
        ImageView logo = (ImageView) this.findViewById(R.id.logo);
        logo.setImageDrawable(logoResource);
    }

    // retrieves the password edit text field and updates it to the
    // sans serif typeface and then updates the transformation method
    EditText password = (EditText) this.findViewById(R.id.password);
    password.setTypeface(Typeface.SANS_SERIF);
    password.setTransformationMethod(new PasswordTransformationMethod());
    password.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                self.login();
            }
            return false;
        }
    });

    // retrieves the reference to the various button in the current activity
    // and registers the current instance as the click listener
    Button signIn = (Button) findViewById(R.id.sign_in);
    signIn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            self.login();
        }
    });
}

From source file:com.ayoview.sample.textview.badge.ViewsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.badge_fragment_views, null);

    View backgroundDefaultView = layout.findViewById(R.id.backgroundDefault);
    backgroundDefaultBadge = new BadgeView(getActivity());
    backgroundDefaultBadge.setBadgeCount(42);
    backgroundDefaultBadge.setTargetView(backgroundDefaultView);

    View backgroundDrawableView = layout.findViewById(R.id.backgroundDrawable);
    backgroundDrawableBadge = new BadgeView(getActivity());
    backgroundDrawableBadge.setBadgeCount(88);
    backgroundDrawableBadge.setBackgroundResource(R.drawable.badge_blue);
    backgroundDrawableBadge.setTargetView(backgroundDrawableView);

    View backgroundShapeView = layout.findViewById(R.id.backgroundShape);
    backgroundShapeBadge = new BadgeView(getActivity());
    backgroundShapeBadge.setBadgeCount(47);
    backgroundShapeBadge.setBackground(12, Color.parseColor("#9b2eef"));
    backgroundShapeBadge.setTargetView(backgroundShapeView);

    View counterView = layout.findViewById(R.id.counter);
    counterView.setOnClickListener(this);
    counterBadge = new BadgeView(getActivity());
    counterBadge.setBadgeCount(-2);/* w  w w .j  a  va  2  s  .c om*/
    counterBadge.setTargetView(counterView);

    View gravityView = layout.findViewById(R.id.gravity);
    gravityView.setOnClickListener(this);
    gravityBadge = new BadgeView(getActivity());
    gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM);
    gravityBadge.setBadgeCount(4);
    gravityBadge.setTargetView(gravityView);

    View textStyleView = layout.findViewById(R.id.textStyle);
    textStyleView.setOnClickListener(this);
    textStyleBadge = new BadgeView(getActivity());
    textStyleBadge.setBadgeCount(18);
    textStyleBadge.setTargetView(textStyleView);
    textStyleBadge.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));
    textStyleBadge.setShadowLayer(2, -1, -1, Color.GREEN);

    View visibilityView = layout.findViewById(R.id.visibility);
    visibilityView.setOnClickListener(this);
    visibilityBadgeView = new BadgeView(getActivity());
    visibilityBadgeView.setBadgeCount(1);
    visibilityBadgeView.setTargetView(visibilityView);

    return layout;
}

From source file:com.andremion.counterfab.CounterFab.java

public CounterFab(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setUseCompatPadding(true);/*from  ww w . j  a va2 s.  com*/

    final float density = getResources().getDisplayMetrics().density;

    mTextSize = TEXT_SIZE_DP * density;
    float textPadding = TEXT_PADDING_DP * density;

    mAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    mAnimationFactor = 1;

    mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTextPaint.setStyle(Paint.Style.STROKE);
    mTextPaint.setColor(Color.WHITE);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
    mTextPaint.setTypeface(Typeface.SANS_SERIF);

    mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCirclePaint.setStyle(Paint.Style.FILL);
    ColorStateList colorStateList = getBackgroundTintList();
    if (colorStateList != null) {
        mCirclePaint.setColor(colorStateList.getDefaultColor());
    } else {
        Drawable background = getBackground();
        if (background instanceof ColorDrawable) {
            ColorDrawable colorDrawable = (ColorDrawable) background;
            mCirclePaint.setColor(colorDrawable.getColor());
        }
    }

    mMaskPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mMaskPaint.setStyle(Paint.Style.FILL);
    mMaskPaint.setColor(MASK_COLOR);

    Rect textBounds = new Rect();
    mTextPaint.getTextBounds(MAX_COUNT_TEXT, 0, MAX_COUNT_TEXT.length(), textBounds);
    mTextHeight = textBounds.height();

    float textWidth = mTextPaint.measureText(MAX_COUNT_TEXT);
    float circleRadius = Math.max(textWidth, mTextHeight) / 2f + textPadding;
    mCircleBounds = new Rect(0, 0, (int) (circleRadius * 2), (int) (circleRadius * 2));
    mContentBounds = new Rect();

    onCountChanged();
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_info_drug);
    isStoredInLocal = false;//  w  ww. ja  v a  2 s.  c om
    fiveLastScreen = false;
    helper = new Handler_Sqlite(this);
    helper.open();
    Bundle extras1 = this.getIntent().getExtras();
    if (extras1 != null) {
        infoBundle = extras1.getStringArrayList("generalInfoDrug");
        fiveLastScreen = extras1.getBoolean("fiveLastScreen");
        if (infoBundle == null)
            isStoredInLocal = true;
        if (!isStoredInLocal) {
            initializeGeneralInfoDrug();
            initializeCodesInformation();
            initializeCodes();
        } else {
            drug_name = extras1.getString("drugName");
            codes = helper.getCodes(drug_name);
            codesInformation = helper.getCodesInformation(drug_name);
        }
        //Title
        TextView drugTitle = (TextView) findViewById(R.id.drugTitle);
        drugTitle.setText(drug_name);
        drugTitle.setTypeface(Typeface.SANS_SERIF);

        //Description 
        LinearLayout borderDescription = new LinearLayout(this);
        borderDescription.setOrientation(LinearLayout.VERTICAL);
        borderDescription
                .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        borderDescription.setBackgroundResource(R.drawable.layout_border);

        TextView description = new TextView(this);
        if (isStoredInLocal)
            description.setText(helper.getDescription(drug_name));
        else
            description.setText(this.description);
        description.setTextSize(18);
        description.setTypeface(Typeface.SANS_SERIF);

        LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        paramsDescription.leftMargin = 60;
        paramsDescription.rightMargin = 60;
        paramsDescription.topMargin = 20;

        borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription);

        LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription);
        layoutDescription.addView(borderDescription, layoutDescription.getChildCount());

        //Animals
        TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals);
        headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton);
        cetaceansButton.setText("CETACEANS");
        cetaceansButton.setTypeface(Typeface.SANS_SERIF);
        cetaceansButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Cetaceans");
            }
        });

        Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton);
        pinnipedsButton.setText("PINNIPEDS");
        pinnipedsButton.setTypeface(Typeface.SANS_SERIF);
        pinnipedsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                SQLiteDatabase db = helper.open();
                ArrayList<String> families = new ArrayList<String>();
                if (db != null)
                    families = helper.read_animals_family(drug_name, "Pinnipeds");
                if ((families != null && families.size() == 1 && families.get(0).equals(""))
                        || (families != null && families.size() == 0))
                    showDoseInformation(drug_name, "Pinnipeds");
                else
                    showDoseInformationPinnipeds(drug_name, families);
            }
        });

        Button otherButton = (Button) findViewById(R.id.otherButton);
        otherButton.setText("OTHER MM");
        otherButton.setTypeface(Typeface.SANS_SERIF);
        otherButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                showDoseInformation(drug_name, "Other MM");
            }
        });

        //Codes & therapeutic target & anatomical target
        TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes);
        headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        //Action
        TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical);
        headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewAnatomical();
        createBorderAnatomicalGroup();

        TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic);
        headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        createTextViewTherapeutic();
        createBorderTherapeuticGroup();

        params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.leftMargin = 60;
        params.rightMargin = 60;
        params.topMargin = 20;

        Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner);
        SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes);
        adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item);
        codesSpinner.setAdapter(adapterCodes);
        codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

            public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
                userEntryCode = parent.getSelectedItem().toString();
                int numCodes = codesInformation.size();

                layoutAnatomicalGroup.removeView(borderAnatomicalGroup);
                createBorderAnatomicalGroup();

                boolean founded = false;
                int i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewAnatomical();
                        anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n");
                        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }

                layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
                layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
                layoutTherapeuticGroup.removeView(borderTherapeuticGroup);
                createBorderTherapeuticGroup();
                founded = false;
                i = 0;
                while (!founded && i < numCodes) {
                    if (userEntryCode.equals(codesInformation.get(i).getCode())) {
                        createTextViewTherapeutic();
                        therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n");
                        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(),
                                params);
                        founded = true;
                    }
                    i++;
                }
                layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);
                layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());
            }

            public void onNothingSelected(AdapterView<?> arg0) {
            }
        });

        layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical);
        layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic);

        borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params);
        borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params);

        layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount());
        layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount());

        //Generic Drug
        TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug);
        headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
        boolean isAvalaible = false;
        if (isStoredInLocal)
            isAvalaible = helper.isAvalaible(drug_name);
        else
            isAvalaible = available.equals("Yes");
        if (isAvalaible) {
            ImageView genericDrug = new ImageView(this);
            genericDrug.setImageResource(R.drawable.tick_verde);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        } else {
            Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
            TextView genericDrug = new TextView(this);
            genericDrug.setTypeface(font);
            genericDrug.setText("Nd");
            genericDrug.setTextColor(getResources().getColor(R.color.maroon));
            genericDrug.setTextSize(20);
            DisplayMetrics metrics = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(metrics);
            int size = metrics.widthPixels;
            int middle = size / 2;
            int quarter = size / 4;
            genericDrug.setTranslationX(middle - quarter);
            genericDrug.setTranslationY(-3);
            LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug);
            layoutGenericDrug.addView(genericDrug);
        }

        //Licenses
        TextView headerLicense = (TextView) findViewById(R.id.headerLicense);
        headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);

        TextView fdaLicense = (TextView) findViewById(R.id.license1);
        Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf");
        fdaLicense.setTypeface(font);

        String fda;
        if (isStoredInLocal)
            fda = helper.getLicense_FDA(drug_name);
        else
            fda = license_FDA;
        if (fda.equals("Yes")) {
            fdaLicense.setText("Yes");
            fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            fdaLicense.setText("Nd");
            fdaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView emaLicense = (TextView) findViewById(R.id.license3);
        emaLicense.setTypeface(font);
        String ema;
        if (isStoredInLocal)
            ema = helper.getLicense_EMA(drug_name);
        else
            ema = license_EMA;
        if (ema.equals("Yes")) {
            emaLicense.setText("Yes");
            emaLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            emaLicense.setText("Nd");
            emaLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        TextView aempsLicense = (TextView) findViewById(R.id.license2);
        aempsLicense.setTypeface(font);
        String aemps;
        if (isStoredInLocal)
            aemps = helper.getLicense_AEMPS(drug_name);
        else
            aemps = license_AEMPS;
        if (aemps.equals("Yes")) {
            aempsLicense.setText("Yes");
            aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen));
        } else {
            aempsLicense.setText("Nd");
            aempsLicense.setTextColor(getResources().getColor(R.color.maroon));
        }

        ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug);
        food_and_drug.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm"));
                startActivity(intent);
            }
        });

        ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency);
        european_medicines_agency.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c"));
                startActivity(intent);
            }
        });

        ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps);
        logo_aemps.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(
                        "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm"));
                startActivity(intent);
            }

        });

        if (helper.existDrug(drug_name)) {
            int drug_priority = helper.getDrugPriority(drug_name);
            ArrayList<String> sorted_drugs = new ArrayList<String>();
            sorted_drugs.add(0, drug_name);
            for (int i = 1; i < drug_priority; i++) {
                String name = helper.getDrugName(i);
                sorted_drugs.add(i, name);
            }

            for (int i = 0; i < sorted_drugs.size(); i++)
                helper.setDrugPriority(sorted_drugs.get(i), i + 1);
        }

        if (!isStoredInLocal) {
            //Server code
            String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=",
                    "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" };
            new GetDoseInformation(this).execute(urls);
        }

        helper.close();
    }

}

From source file:org.npr.android.news.NewsListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = inflater.inflate(R.layout.news_item, parent, false);
    }/*ww w .  j  a  v  a2 s .  c o  m*/

    Story story = getItem(position);

    ImageView image = (ImageView) convertView.findViewById(R.id.NewsItemImage);
    TextView teaser = (TextView) convertView.findViewById(R.id.NewsItemTeaserText);
    TextView name = (TextView) convertView.findViewById(R.id.NewsItemNameText);

    if (story != null) {
        image.setImageDrawable(getContext().getResources()
                .getDrawable(isPlayable(story) ? R.drawable.icon_listen_main : R.drawable.bullet));
        image.setVisibility(View.VISIBLE);
        name.setTypeface(headlineTypeface, Typeface.NORMAL);
        name.setText(story.toString());
        String teaserText = story.getMiniTeaser();
        if (teaserText == null) {
            teaserText = story.getTeaser();
        }
        if (teaserText != null && teaserText.length() > 0) {
            // Disable for now.
            //        teaser.setText(story.getTeaser());
            //        teaser.setVisibility(View.VISIBLE);
        } else {
            teaser.setVisibility(View.INVISIBLE);
        }
        teaser.setVisibility(View.GONE);
    } else {
        // null marker means it's the end of the list.
        image.setVisibility(View.INVISIBLE);
        teaser.setVisibility(View.INVISIBLE);
        name.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);
        name.setText(R.string.msg_load_more);
    }
    return convertView;
}

From source file:bander.notepad.NoteEditAppCompat.java

@Override
protected void onResume() {
    super.onResume();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    // Font size/*from   w  ww . j  a  va 2s . c o  m*/
    float textSize = Float.valueOf(preferences.getString("textSize", "16"));
    mBodyText.setTextSize(textSize);
    // Monospace font
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    boolean typeface = settings.getBoolean("typeface", true);
    if (typeface) {
        Typeface font = Typeface.MONOSPACE;
        mBodyText.setTypeface(font);
    } else {
        mBodyText.setTypeface(Typeface.SANS_SERIF);
    }
    // Auto-correct
    boolean input = preferences.getBoolean("inputType", true);
    if (input) {
        // AutoCorrect on
        mBodyText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE);
    } else {
        // AutoCorrect off
        mBodyText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    }

    Cursor cursor = getContentResolver().query(mUri, PROJECTION, null, null, null);
    Note note = Note.fromCursor(cursor);
    cursor.close();

    if (note != null) {
        if (mOriginalNote == null)
            mOriginalNote = note;
        mBodyText.setTextKeepState(note.getBody());

        Boolean rememberPosition = preferences.getBoolean("rememberPosition", true);
        if (rememberPosition) {
            mBodyText.setSelection(note.getCursor());
            mBodyText.scrollTo(0, note.getScrollY());
        }
    }
}