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:Main.java

/**
 * Create round, coloured bitmap with text embedded.
 * @param circleColor The color to use.//from   w  w  w  . java 2  s  .c  o m
 * @param diameterDP The diameter of the circle.
 * @param text The text to embed.
 * @return Bitmap showing a text.
 */
public static Bitmap generateCircleBitmap(int circleColor, float diameterDP, String text) {
    /**
     *
     * http://stackoverflow.com/questions/31168636/rounded-quickcontactbadge-with-text
     */
    final int textColor = 0xffffffff;

    DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
    float diameterPixels = diameterDP * (metrics.densityDpi / 160f);
    float radiusPixels = diameterPixels / 2;

    // Create the bitmap
    Bitmap output = Bitmap.createBitmap((int) diameterPixels, (int) diameterPixels, Bitmap.Config.ARGB_8888);

    // Create the canvas to draw on
    Canvas canvas = new Canvas(output);
    canvas.drawARGB(0, 0, 0, 0);

    // Draw the circle
    final Paint paintC = new Paint();
    paintC.setAntiAlias(true);
    paintC.setColor(circleColor);
    canvas.drawCircle(radiusPixels, radiusPixels, radiusPixels, paintC);

    // Draw the text
    if (text != null && text.length() > 0) {
        final Paint paintT = new Paint();
        paintT.setColor(textColor);
        paintT.setAntiAlias(true);
        paintT.setTextSize(radiusPixels * 2);
        paintT.setTypeface(Typeface.SANS_SERIF);
        final Rect textBounds = new Rect();
        paintT.getTextBounds(text, 0, text.length(), textBounds);
        canvas.drawText(text, radiusPixels - textBounds.exactCenterX(),
                radiusPixels - textBounds.exactCenterY(), paintT);
    }

    return output;
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewpager_mainmenu);
    helper = new Handler_Sqlite(this);
    PagerTabStrip mPagerTabStrip = (PagerTabStrip) findViewById(R.id.title);
    int size = mPagerTabStrip.getChildCount();
    for (int i = 0; i < size; i++) {
        View child = mPagerTabStrip.getChildAt(i);
        if (child instanceof TextView) {
            textView = (TextView) child;
            textView.setTypeface(Typeface.SANS_SERIF);
        }//from  ww  w  . j av a 2 s. c  o  m
    }

    ViewPager vpPager = (ViewPager) findViewById(R.id.vp_mainmenu);
    adapterViewPager = new MyPagerAdapter(getSupportFragmentManager());
    vpPager.setAdapter(adapterViewPager);
    Bundle extra = this.getIntent().getExtras();
    if (extra != null) {
        if (extra.getInt("dosis") == 2)
            vpPager.setCurrentItem(2);
        else
            vpPager.setCurrentItem(3);
    } else
        vpPager.setCurrentItem(1);

}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    helper = new Handler_Sqlite(this);
    extra = this.getIntent().getExtras();
    setContentView(R.layout.viewpager_pinnipeds);
    TextView drug = (TextView) findViewById(R.id.title);
    if (extra != null) {
        drug.setText(extra.getCharSequence("drugName"));
        Handler_Sqlite helper = new Handler_Sqlite(this);
        SQLiteDatabase db = helper.open();
        families = new ArrayList<String>();
        if (db != null)
            families = helper.read_animals_family(extra.getString("drugName"), "Pinnipeds");
    }/* w w  w  .  j a  va2  s.  co  m*/
    drug.setTypeface(Typeface.SANS_SERIF);
    TextView group = (TextView) findViewById(R.id.subtitle);
    group.setTypeface(Typeface.SANS_SERIF);
    PagerTabStrip mPagerTabStrip = (PagerTabStrip) findViewById(R.id.tabs);
    if (families.size() == 1)
        mPagerTabStrip.setTabIndicatorColor(getResources().getColor(android.R.color.white));
    int size = mPagerTabStrip.getChildCount();
    for (int i = 0; i < size; i++) {
        View child = mPagerTabStrip.getChildAt(i);
        if (child instanceof TextView) {
            textView = (TextView) child;
            textView.setTypeface(Typeface.SANS_SERIF);
        }
    }
    ViewPager vpPager = (ViewPager) findViewById(R.id.vp_pinnipeds);
    adapterViewPager = new MyPagerAdapter(getSupportFragmentManager());
    vpPager.setAdapter(adapterViewPager);
    vpPager.setCurrentItem(1);

}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.combined_search);
    helper = new Handler_Sqlite(this);
    userEntryAnatomicalTarget = "";
    userEntryTherapeuticTarget = "";
    userEntryAnimalTarget = "";
    TextView title = (TextView) findViewById(R.id.CombinedSearch);
    title.setTypeface(Typeface.SANS_SERIF);
    Button go = (Button) findViewById(R.id.goButton);
    go.setTypeface(Typeface.SANS_SERIF);
    go.setOnClickListener(new OnClickListener() {

        @Override//from   w  w  w .  jav a 2 s .c om
        public void onClick(View v) {
            userEntryTherapeuticTarget = actv.getText().toString();
            search();
        }

    });

    Spinner spinnerAnatomicalTarget = (Spinner) findViewById(R.id.SpinAnatomicalTarget);
    SpinnerAdapter adapterAnatomicalTarget = new SpinnerAdapter(this, R.layout.item_spinner,
            Arrays.asList(getResources().getStringArray(R.array.AnatomicalTarget)));
    adapterAnatomicalTarget.setDropDownViewResource(R.layout.spinner_dropdown_item);
    spinnerAnatomicalTarget.setAdapter(adapterAnatomicalTarget);
    spinnerAnatomicalTarget.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
            userEntryAnatomicalTarget = parent.getSelectedItem().toString();
        }

        public void onNothingSelected(AdapterView<?> arg0) {

        }
    });

    String[] urls = { "http://formmulary.tk/Android/getTherapeuticGroups.php" };
    new GetTherapeuticGroups(this).execute(urls);
    Spinner spinnerAnimals = (Spinner) findViewById(R.id.SpinAnimals);
    SpinnerAdapter adapterAnimals = new SpinnerAdapter(this, R.layout.item_spinner,
            Arrays.asList(getResources().getStringArray(R.array.Animals)));
    adapterAnimals.setDropDownViewResource(R.layout.spinner_dropdown_item);
    spinnerAnimals.setAdapter(adapterAnimals);

    spinnerAnimals.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) {
            userEntryAnimalTarget = parent.getSelectedItem().toString();
        }

        public void onNothingSelected(AdapterView<?> arg0) {

        }
    });

}

From source file:com.tr4android.support.extension.typeface.TypefaceCompat.java

@Deprecated
private static void initialize() {
    Log.w("TypefaceCompat",
            "TypefaceCompat is deprecated. Use downloadable fonts or FontsContractCompat instead.");
    if (mTypefaceDetectionEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        Typeface roboto = Typeface.createFromFile(SYSTEM_ROBOTO_REGULAR_FILE_PATH);
        if (roboto != null) {
            mIsUsingDefaultFont = TypefaceUtils.sameAs(roboto, Typeface.SANS_SERIF);
        }/*from w w  w  .j a va 2s .c om*/
    }
    mInitialized = true;
}

From source file:com.farmerbb.notepad.adapter.NoteListAdapter.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();

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

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

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

    // 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));

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

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

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

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

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

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

From source file:com.anjalimacwan.adapter.NoteListAdapter.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();

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

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

    // Populate the data into the template view using the data object
    noteTitle.setText(note);/*from  www . ja v  a  2s .c o  m*/

    // 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));

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

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

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

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

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

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

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dose_information);

    Bundle parameters = this.getIntent().getExtras();
    if (parameters != null) {
        TextView textViewDrug = (TextView) findViewById(R.id.textView_drug_name);
        textViewDrug.setTypeface(Typeface.SANS_SERIF);
        textViewDrug.setText(parameters.getString("drugName"));
        TextView textViewGroupName = (TextView) findViewById(R.id.textView_group_name);
        textViewGroupName.setTypeface(Typeface.SANS_SERIF);
        textViewGroupName.setText("(" + parameters.getString("groupName") + ")");
        layoutDose = (LinearLayout) findViewById(R.id.layout_dose);

        helper = new Handler_Sqlite(this);
        SQLiteDatabase db = helper.open();
        ArrayList<String> notes_index = new ArrayList<String>();
        ArrayList<String> references = new ArrayList<String>();
        ArrayList<Article_Reference> references_index = new ArrayList<Article_Reference>();
        reference_index = 'a';
        ArrayList<String> families = new ArrayList<String>();
        if (db != null)
            families = helper.read_animals_family(parameters.getString("drugName"),
                    parameters.getString("groupName"));

        for (int l = 0; l < families.size(); l++) {
            //if exists animals family

            TextView textView_family = new TextView(this);
            textView_family.setText(families.get(l));
            textView_family.setTextSize(20);
            textView_family.setTextColor(getResources().getColor(R.color.darkGray));
            textView_family.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());

            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            params.leftMargin = 30;//from  ww  w. ja  v a 2 s . co m
            params.topMargin = 20;
            layoutDose.addView(textView_family, layoutDose.getChildCount(), params);

            //dose information

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

            ArrayList<Dose_Data> dose = new ArrayList<Dose_Data>();
            if (db != null) {
                dose = helper.read_dose_information(parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l), "", "");
            }
            TableLayout doseTable = new TableLayout(this);
            doseTable.setStretchAllColumns(true);

            screenWidth = Integer.parseInt(getString(R.string.display));

            TableRow header = new TableRow(this);

            //Amount

            TextView textView_dose_amount = new TextView(this);
            textView_dose_amount.setText("Dose");
            textView_dose_amount.setSingleLine(true);
            textView_dose_amount.setTextColor(getResources().getColor(R.color.darkGray));
            textView_dose_amount.setTextSize(17);
            textView_dose_amount.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsAmount.gravity = Gravity.CENTER;
            header.addView(textView_dose_amount, paramsAmount);

            //Posology
            TextView textView_posology = new TextView(this);
            if (screenWidth >= 720)
                textView_posology.setText("Posology");
            else
                textView_posology.setText("Pos");
            textView_posology.setSingleLine(true);
            textView_posology.setTextColor(getResources().getColor(R.color.darkGray));
            textView_posology.setTextSize(17);
            textView_posology.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsPosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsPosology.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"),
                    parameters.getString("groupName"), families.get(l), "Posology")) || screenWidth >= 600)
                header.addView(textView_posology, paramsPosology);

            //Route

            TextView textView_route = new TextView(this);
            textView_route.setText("Route");
            textView_route.setSingleLine(true);
            textView_route.setTextColor(getResources().getColor(R.color.darkGray));
            textView_route.setTextSize(17);
            textView_route.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsRoute = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                    TableRow.LayoutParams.WRAP_CONTENT);
            paramsRoute.gravity = Gravity.CENTER;
            header.addView(textView_route, paramsRoute);

            //Reference

            TextView textView_reference = new TextView(this);
            textView_reference.setText("Ref");
            textView_reference.setSingleLine(true);
            textView_reference.setTextColor(getResources().getColor(R.color.darkGray));
            textView_reference.setTextSize(17);
            textView_reference.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsReference = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsReference.gravity = Gravity.CENTER;
            header.addView(textView_reference, paramsReference);

            //Specific Note

            TextView textView_specific_note = new TextView(this);
            textView_specific_note.setText("Note");
            textView_specific_note.setSingleLine(true);
            textView_specific_note.setTextColor(getResources().getColor(R.color.darkGray));
            textView_specific_note.setTextSize(17);
            textView_specific_note.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
            TableRow.LayoutParams paramsSpecificNote = new TableRow.LayoutParams(
                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
            paramsSpecificNote.gravity = Gravity.CENTER;
            if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"),
                    parameters.getString("groupName"), families.get(l), "Note")) || screenWidth >= 600)
                header.addView(textView_specific_note, paramsSpecificNote);

            TableRow doseData = new TableRow(this);
            doseTable.addView(header);

            //General Dose

            if (dose.size() > 0) {
                show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l), "", "", notes_index, references,
                        references_index);
            }

            HashMap<String, ArrayList<String>> animal_information = new HashMap<String, ArrayList<String>>();
            if (db != null)
                animal_information = helper.read_animal_information(parameters.getString("drugName"),
                        parameters.getString("groupName"), families.get(l));

            String animalName;
            Object[] animalsName = animal_information.keySet().toArray();
            for (int i = 0; i < animalsName.length; i++) {
                doseData = new TableRow(this);

                //if exists animal name
                animalName = (String) animalsName[i];
                TextView textView_animal_name = new TextView(this);
                if (!animalName.equals("")) {

                    //Animal name

                    textView_animal_name.setText(animalName);
                    textView_animal_name.setSingleLine(false);
                    textView_animal_name.setTextColor(getResources().getColor(R.color.darkGray));
                    textView_animal_name.setTextSize(15);
                    textView_animal_name.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle());
                }

                //if exists category
                ArrayList<String> categories = animal_information.get(animalName);
                String animalCategory;
                for (int j = 0; j < categories.size(); j++) {

                    animalCategory = categories.get(j);

                    if (!animalCategory.equals("")) {

                        //Animal category

                        TextView textView_animal_category = new TextView(this);
                        textView_animal_category.setText(animalCategory);
                        textView_animal_category.setSingleLine(false);
                        textView_animal_category.setTextColor(Color.BLACK);
                        textView_animal_category.setTextSize(15);
                        textView_animal_category.setTypeface(Typeface.SANS_SERIF);
                        if (!animalName.equals("")) {
                            if (j == 0) {
                                TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams(
                                        TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                                if (screenWidth < 600
                                        && isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Posology")
                                        && isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Note"))
                                    paramsAnimalName.span = 3;
                                else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Posology")
                                        || isCollapsed(parameters.getString("drugName"),
                                                parameters.getString("groupName"), families.get(l), "Note")))
                                    paramsAnimalName.span = 4;
                                else
                                    paramsAnimalName.span = 5;

                                doseData.addView(textView_animal_name, paramsAnimalName);
                                doseTable.addView(doseData);
                            }

                            if (db != null)
                                dose = helper.read_dose_information(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), animalName,
                                        animalCategory);

                            doseData = new TableRow(this);
                            textView_animal_category.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC);
                            TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams(
                                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                            if (screenWidth < 600
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Posology")
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note"))
                                paramsCategoryName.span = 3;
                            else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), "Posology")
                                    || isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note")))
                                paramsCategoryName.span = 4;
                            else
                                paramsCategoryName.span = 5;
                            if (screenWidth < 600)
                                paramsCategoryName.leftMargin = 15;
                            else if (screenWidth >= 600 && screenWidth < 720)
                                paramsCategoryName.leftMargin = 20;
                            else
                                paramsCategoryName.leftMargin = 30;
                            doseData.addView(textView_animal_category, paramsCategoryName);
                            doseTable.addView(doseData);
                            doseData = new TableRow(this);
                            show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory, notes_index, references, references_index);

                            doseData = new TableRow(this);
                        } else {
                            if (db != null)
                                dose = helper.read_dose_information(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), animalName,
                                        animalCategory);

                            textView_animal_category.setTypeface(Typeface.SANS_SERIF,
                                    Typeface.DEFAULT_BOLD.getStyle());
                            textView_animal_category.setTextColor(getResources().getColor(R.color.darkGray));
                            TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams(
                                    TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                            if (screenWidth < 600
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Posology")
                                    && isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note"))
                                paramsCategoryName.span = 3;
                            else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), "Posology")
                                    || isCollapsed(parameters.getString("drugName"),
                                            parameters.getString("groupName"), families.get(l), "Note")))
                                paramsCategoryName.span = 4;
                            else
                                paramsCategoryName.span = 5;
                            doseData.addView(textView_animal_category, paramsCategoryName);
                            doseTable.addView(doseData);
                            doseData = new TableRow(this);
                            show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory, notes_index, references, references_index);

                            doseData = new TableRow(this);
                        }

                    }

                    if (!animalName.equals("") && animalCategory.equals("")) {
                        if (db != null)
                            dose = helper.read_dose_information(parameters.getString("drugName"),
                                    parameters.getString("groupName"), families.get(l), animalName,
                                    animalCategory);

                        TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams(
                                TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
                        if (screenWidth < 600
                                && isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Posology")
                                && isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Note"))
                            paramsAnimalName.span = 3;
                        else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"),
                                parameters.getString("groupName"), families.get(l), "Posology")
                                || isCollapsed(parameters.getString("drugName"),
                                        parameters.getString("groupName"), families.get(l), "Note")))
                            paramsAnimalName.span = 4;
                        else
                            paramsAnimalName.span = 5;
                        doseData.addView(textView_animal_name, paramsAnimalName);
                        doseTable.addView(doseData);
                        doseData = new TableRow(this);
                        show_dose(dose, doseTable, doseData, parameters.getString("drugName"),
                                parameters.getString("groupName"), families.get(l), animalName, animalCategory,
                                notes_index, references, references_index);

                        doseData = new TableRow(this);
                    }
                }

            }

            LinearLayout.LayoutParams paramsDoseTable = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            if (screenWidth >= 600) {
                paramsDoseTable.topMargin = 5;
                paramsDoseTable.leftMargin = 50;
                paramsDoseTable.rightMargin = 50;
            } else {
                paramsDoseTable.topMargin = 5;
                paramsDoseTable.leftMargin = 60;
                paramsDoseTable.rightMargin = 30;
            }
            layout_dose_information.addView(doseTable, paramsDoseTable);

            layoutDose.addView(layout_dose_information, layoutDose.getChildCount());
        }
        helper.close();

        //Notes
        additionalInformationInterface("GENERAL NOTES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);
        additionalInformationInterface("SPECIFIC NOTES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);
        //References
        additionalInformationInterface("REFERENCES", parameters.getString("drugName"),
                parameters.getString("groupName"), notes_index, references_index);

    }

}

From source file:com.farmerbb.notepad.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 = convertView.findViewById(R.id.noteTitle);
    TextView noteDate = convertView.findViewById(R.id.noteDate);

    // Populate the data into the template view using the data object
    noteTitle.setText(note);//from w ww .j a v a  2  s  .c o 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:com.sachinshinde.theweatherapp.utils.LUtils.java

public void setMediumTypeface(TextView textView) {
    if (hasL()) {
        if (sMediumTypeface == null) {
            sMediumTypeface = Typeface.create("sans-serif-medium", Typeface.NORMAL);
        }//from  www .  j  a va2  s  .  com

        textView.setTypeface(sMediumTypeface);
    } else {
        textView.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    }
}