Example usage for android.widget TextView setTypeface

List of usage examples for android.widget TextView setTypeface

Introduction

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

Prototype

public void setTypeface(@Nullable Typeface tf) 

Source Link

Document

Sets the typeface and style in which the text should be displayed.

Usage

From source file:com.bangz.shotrecorder.RecordActivity.java

private void setDigitFont() {

    Typeface tfItalic = TypefaceCache.getTypeface(TypefaceCache.FONT_ITALIC_PATH, this);
    Typeface tfNormal = TypefaceCache.getTypeface(TypefaceCache.FONT_NORMAL_PATH, this);

    TextView v = (TextView) findViewById(R.id.textTIME);
    textTIME = v;//from   w ww  .  j  a va  2s. c  o m

    v.setTypeface(tfItalic); // style bold | italic = 1| 2 = 3;

    v = (TextView) findViewById(R.id.textElapsedTime);
    v.setTypeface(tfItalic);
    textElapsed = v;

    v = (TextView) findViewById(R.id.textTimeLable);
    v.setTypeface(tfNormal);

    v = (TextView) findViewById(R.id.textmode);
    v.setTypeface(tfNormal);

    v = (TextView) findViewById(R.id.textModePrefix);
    v.setTypeface(tfNormal);

    v = (TextView) findViewById(R.id.textModeValue);
    v.setTypeface(tfNormal);

    v = (TextView) findViewById(R.id.textNumberLabel);
    v.setTypeface(tfItalic);

    v = (TextView) findViewById(R.id.textNumber);
    v.setTypeface(tfItalic);
    textNumber = v;

    v = (TextView) findViewById(R.id.textSplitLabel);
    v.setTypeface(tfItalic);

    v = (TextView) findViewById(R.id.textSplit);
    v.setTypeface(tfItalic);
    textSplit = v;
}

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);//from ww w.  j av a  2  s.  c  om

    // 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:brostore.maquillage.custom.PagerSlidingTabStrip.java

private void addCustomTextTab(final int position, String title) {
    LinearLayout conteneur = new LinearLayout(getContext());
    LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    conteneur.setOrientation(LinearLayout.HORIZONTAL);
    conteneur.setGravity(Gravity.CENTER);
    TextView tab = new TextView(getContext());
    TextView tabCust = new TextView(getContext());
    //tabCust.setBackgroundResource(R.drawable.live_nombre);
    tabCust.setGravity(Gravity.CENTER);//from  w w w  . j a  v a  2s  .  c  o  m
    tabCust.setTextColor(Color.WHITE);
    tabCust.setTypeface(tabTypeface);
    tabCust.setTextSize(11);
    tabCust.setVisibility(View.GONE);
    int fiveDip = Utils.convertDpToPixel(5, getResources());
    tabCust.setPadding(fiveDip, 0, fiveDip, 0);
    tabCust.setText("0");
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    conteneur.addView(tab, param);
    param.leftMargin = Utils.convertDpToPixel(10, getResources());
    conteneur.addView(tabCust, param);
    addTab(position, conteneur);
}

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   w  ww  . j ava2  s  .  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.github.irshulx.Components.InputExtensions.java

private void addEditableStyling(TextView editText) {
    editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL));
    editText.setFocusableInTouchMode(true);
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE);
    editText.setTextColor(Color.parseColor(this.DEFAULT_TEXT_COLOR));
    editText.setPadding(0, 30, 0, 30);//from  w w w  .  ja v a 2 s.com
}

From source file:com.example.sam.savemeapp.StatisticsFragment.java

/**
 * Sets up the initial legend with the contained categories shown
 * in the pie chart and bullet points with the corresponding colors.
 *//*from  w  ww  .  j  a va 2 s.co  m*/
public void setUpPiechart() {
    pieChart.getDescription().setEnabled(false);
    Legend pieL = pieChart.getLegend();
    Log.d("stats", Float.toString(pieL.getEntries().length));
    startLegend = pieL;
    LegendEntry[] legends = pieL.getEntries();
    pieL.setEnabled(false);
    mLegend.removeAllViews();
    //The default legend consist of TextViews and ImageViews which contains a bullet point.
    //The legends are contained inside of a horizontal LinearLayout which is contained in a vertical LinearLayout.
    for (int t = 0; t < legends.length - 1; t++) {
        LegendEntry x = legends[t];
        LinearLayout hLayout = new LinearLayout(getContext());
        hLayout.setLayoutParams(params);
        TextView tv = new TextView(getContext());
        tv.setText(x.label);
        tv.setTextColor(x.formColor);
        tv.setTypeface(fontLight);
        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                getResources().getDimension(R.dimen.statistics_main_text_size));
        tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
        LinearLayoutCompat.LayoutParams textViewParams = new LinearLayoutCompat.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        textViewParams.setMarginStart((int) getResources().getDimension(R.dimen.statistics_text_margin));
        tv.setLayoutParams(textViewParams);
        ImageView iv = new ImageView(getContext());
        Drawable dot = ContextCompat.getDrawable(getContext(), R.drawable.circle_legend);
        dot.setColorFilter(x.formColor, PorterDuff.Mode.SRC);
        iv.setImageDrawable(dot);
        iv.setLayoutParams(new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        hLayout.addView(iv);
        hLayout.addView(tv);
        mLegend.addView(hLayout);
    }

    designPiechart();

    pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
        private int color;

        @Override
        public void onValueSelected(Entry e, Highlight h) {
            //it creates new legends with the information of the subcategories when a
            // category in the pi chart is clicked
            ArrayList<LegendEntry> list = new ArrayList<>();
            mLegend.removeAllViews();
            if (e.getData().equals(Color.parseColor("#00a0ae"))) {
                for (LegendEntry x : startLegend.getEntries()) {
                    if (x.label.equals("Food & Beverage")) {
                        color = x.formColor;
                    }
                }
                list.add(new LegendEntry("Food & Beverage: "
                        + u.categories.get("Food & Beverage").get("Food & Beverage") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Restaurant & Caf: "
                        + u.categories.get("Food & Beverage").get("Restaurant & Caf") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Supermarket: " + u.categories.get("Food & Beverage").get("Supermarket") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                mLegend.removeAllViews();
                //This category legends consist of the main category in this case "Food & Beverage" in the top of the legend
                //and the sub categories bellow. The name is also shown together with the amount spend in that category.
                for (LegendEntry x : list) {
                    TextView tv = new TextView(getContext());
                    if (x.equals(list.get(0))) {
                        tv.setTypeface(fontBlack);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_main_text_size));
                    } else {
                        tv.setTypeface(fontLight);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_text_size));
                    }
                    tv.setText(x.label);
                    tv.setTextColor(color);
                    tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    mLegend.addView(tv);
                }
            } else if (e.getData().equals(Color.parseColor("#be3127"))) {
                for (LegendEntry x : startLegend.getEntries()) {
                    if (x.label.equals("Transportation")) {
                        color = x.formColor;
                    }
                }
                list.add(new LegendEntry("Transportation: "
                        + u.categories.get("Transportation").get("Transportation") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Public transport: "
                        + u.categories.get("Transportation").get("Public transport") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Taxi & Uber: " + u.categories.get("Transportation").get("Taxi & Uber") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Petrol: " + u.categories.get("Transportation").get("Petrol") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Maintenance: " + u.categories.get("Transportation").get("Maintenance") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                mLegend.removeAllViews();
                for (LegendEntry x : list) {
                    TextView tv = new TextView(getContext());
                    if (x.equals(list.get(0))) {
                        tv.setTypeface(fontBlack);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_main_text_size));
                    } else {
                        tv.setTypeface(fontLight);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_text_size));
                    }
                    tv.setText(x.label);
                    tv.setTextColor(color);
                    tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    mLegend.addView(tv);
                }
            } else if (e.getData().equals(Color.parseColor("#7dc725"))) {
                for (LegendEntry x : startLegend.getEntries()) {
                    if (x.label.equals("Shopping")) {
                        color = x.formColor;
                    }
                }
                list.add(new LegendEntry(
                        "Shopping: " + u.categories.get("Shopping").get("Shopping") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Clothing: " + u.categories.get("Shopping").get("Clothing") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Electronics: " + u.categories.get("Shopping").get("Electronics") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Books: " + u.categories.get("Shopping").get("Books") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Gifts: " + u.categories.get("Shopping").get("Gifts") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Other: " + u.categories.get("Shopping").get("Other") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                mLegend.removeAllViews();
                for (LegendEntry x : list) {
                    TextView tv = new TextView(getContext());
                    if (x.equals(list.get(0))) {
                        tv.setTypeface(fontBlack);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_main_text_size));
                    } else {
                        tv.setTypeface(fontLight);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_text_size));
                    }
                    tv.setText(x.label);
                    tv.setTextColor(color);
                    tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    mLegend.addView(tv);
                }
            } else if (e.getData().equals(Color.parseColor("#e88300"))) {
                for (LegendEntry x : startLegend.getEntries()) {
                    if (x.label.equals("Entertainment")) {
                        color = x.formColor;
                    }
                }
                list.add(new LegendEntry(
                        "Entertainment: " + u.categories.get("Entertainment").get("Entertainment") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Going out: " + u.categories.get("Entertainment").get("Going out") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Sports: " + u.categories.get("Entertainment").get("Sports") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                mLegend.removeAllViews();
                for (LegendEntry x : list) {
                    TextView tv = new TextView(getContext());
                    if (x.equals(list.get(0))) {
                        tv.setTypeface(fontBlack);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_main_text_size));
                    } else {
                        tv.setTypeface(fontLight);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_text_size));
                    }
                    tv.setText(x.label);
                    tv.setTextColor(color);
                    tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    mLegend.addView(tv);
                }
            } else if (e.getData().equals(Color.parseColor("#dc006d"))) {
                for (LegendEntry x : startLegend.getEntries()) {
                    if (x.label.equals("Health")) {
                        color = x.formColor;
                    }
                }
                list.add(new LegendEntry("Health: " + u.categories.get("Health").get("Health") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Doctor: " + u.categories.get("Health").get("Doctor") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Pharmacy: " + u.categories.get("Health").get("Pharmacy") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                mLegend.removeAllViews();
                for (LegendEntry x : list) {
                    TextView tv = new TextView(getContext());
                    if (x.equals(list.get(0))) {
                        tv.setTypeface(fontBlack);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_main_text_size));
                    } else {
                        tv.setTypeface(fontLight);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_text_size));
                    }
                    tv.setText(x.label);
                    tv.setTextColor(color);
                    tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    mLegend.addView(tv);
                }
            } else if (e.getData().equals(Color.parseColor("#1562a4"))) {
                for (LegendEntry x : startLegend.getEntries()) {
                    if (x.label.equals("Bills")) {
                        color = x.formColor;
                    }
                }
                list.add(new LegendEntry("Bills: " + u.categories.get("Bills").get("Bills") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Water: " + u.categories.get("Bills").get("Water") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry(
                        "Electricity: " + u.categories.get("Bills").get("Electricity") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Gas: " + u.categories.get("Bills").get("Gas") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Rent: " + u.categories.get("Bills").get("Rent") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Phone: " + u.categories.get("Bills").get("Phone") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(
                        new LegendEntry("Insurance: " + u.categories.get("Bills").get("Insurance") + u.currency,
                                Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("TV: " + u.categories.get("Bills").get("TV") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                list.add(new LegendEntry("Internet: " + u.categories.get("Bills").get("Internet") + u.currency,
                        Legend.LegendForm.SQUARE, 7f, 7f, null, color));
                mLegend.removeAllViews();
                for (LegendEntry x : list) {
                    TextView tv = new TextView(getContext());
                    if (x.equals(list.get(0))) {
                        tv.setTypeface(fontBlack);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_main_text_size));
                    } else {
                        tv.setTypeface(fontLight);
                        tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                                getResources().getDimension(R.dimen.statistics_text_size));
                    }
                    tv.setText(x.label);
                    tv.setTextColor(color);
                    tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                    mLegend.addView(tv);
                }
            }
        }

        @Override
        public void onNothingSelected() {
            //Sets up the default legend when nothing is selected
            pieChart = (PieChart) v.findViewById(R.id.piechart);
            pieChart.setUsePercentValues(true);
            LegendEntry[] legends = startLegend.getEntries();
            startLegend.setEnabled(false);
            mLegend.removeAllViews();
            for (LegendEntry x : legends) {
                LinearLayout hLayout = new LinearLayout(getContext());
                hLayout.setLayoutParams(params);
                TextView tv = new TextView(getContext());
                tv.setText(x.label);
                tv.setTextColor(x.formColor);
                tv.setTypeface(fontLight);
                tv.setTextSize(TypedValue.COMPLEX_UNIT_SP,
                        getResources().getDimension(R.dimen.statistics_main_text_size));
                tv.setTextAlignment(View.TEXT_ALIGNMENT_TEXT_START);
                LinearLayoutCompat.LayoutParams textViewParams = new LinearLayoutCompat.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                textViewParams
                        .setMarginStart((int) getResources().getDimension(R.dimen.statistics_text_margin));
                tv.setLayoutParams(textViewParams);
                ImageView iv = new ImageView(getContext());
                Drawable dot = ContextCompat.getDrawable(getContext(), R.drawable.circle_legend);
                dot.setColorFilter(x.formColor, PorterDuff.Mode.SRC);
                iv.setImageDrawable(dot);
                iv.setLayoutParams(new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                        ViewGroup.LayoutParams.MATCH_PARENT));
                hLayout.addView(iv);
                hLayout.addView(tv);
                mLegend.addView(hLayout);
            }
        }
    });
}

From source file:com.gaadikey.gaadikey.gaadikey.Fragment_Home.java

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home, container, false);

    ImageView thumbnail = (ImageView) view.findViewById(R.id.thumbnail);
    TextView gaadiname_field = (TextView) view.findViewById(R.id.GaadiName);
    TextView gaadimsg_field = (TextView) view.findViewById(R.id.GaadiMsg);
    TextView numberplate_textview = (TextView) view.findViewById(R.id.numberplate);

    numberplate_textview.setOnClickListener(new View.OnClickListener() {
        @Override//from ww w . j  a v a 2s.  c  o  m
        public void onClick(View view) {

            ((LaunchActivity_NavDrawer) getActivity()).displayView(6); // This opens up numberplate view!
        }
    });

    thumbnail.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            // Open up the settings view when clicked from here!
            ((LaunchActivity_NavDrawer) getActivity()).displayView(8); // The 7th option is settings!
        }
    });

    // Download the Image dynamically, Pinging the Image URL
    // Get the image path URL by rading the persistant storage

    SharedPreferences sharedPref = getActivity().getSharedPreferences("android_shared", Context.MODE_PRIVATE);
    IMAGE_PATH = sharedPref.getString(getString(R.string.KEY_GaadiImage), "default");
    //  IMAGE_PATH = "http://gaadikey.com/images/GaadiKey_bikes/bajaj/bajaj-discover-100m.jpg"; // hARD CODING THE IMAGE url TO CHECK IF 37KB IMAGE LOADING IS THE ISSUE
    GAADI_MSG = sharedPref.getString(getString(R.string.KEY_GaadiMsg), "Set status");
    GAADI_NAME = sharedPref.getString(getString(R.string.KEY_GaadiName), "Your Vehicle Name here");

    gaadimsg_field.setText(GAADI_MSG);
    gaadiname_field.setText(GAADI_NAME);

    Log.e("Retrieved IMAGE_PATH ", IMAGE_PATH);
    Log.e("Retrieved GAADI_MSG ", GAADI_MSG);
    Log.e("Retrieved GAADI NAME ", GAADI_NAME);

    if (!IMAGE_PATH.equals("default")) {

        Picasso.with(getActivity().getBaseContext()).load(IMAGE_PATH).into(thumbnail);

    }

    TextView numberplateText = (TextView) view.findViewById(R.id.numberplate);
    SharedPreferences sharedPref1 = getActivity().getSharedPreferences("android_shared", Context.MODE_PRIVATE);
    String numberplatestring = sharedPref1.getString(getString(R.string.KEY_GaadiKey_Number_Saved),
            "KA50Q7896");
    Log.e("The retreived number plate string is ", numberplatestring);

    numberplateText.setText(numberplatestring); // setting the string obtained from the KEY set by number picker change listener
    Typeface typface = Typeface.createFromAsset(getActivity().getAssets(), "LicensePlate.ttf");
    numberplateText.setTypeface(typface);

    lanes.add("Public Lane");
    lanes.add("Friends Lane");
    lanes.add("Safety Lane");
    lanes.add("Shopping Lane");
    lanes.add("News");

    listview = (ListView) view.findViewById(R.id.list);
    listview.setAdapter(new StickyHomeAdapter(getActivity(), lanes));
    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {

            SharedPreferences sharedPref4 = getActivity().getSharedPreferences("android_shared",
                    Context.MODE_PRIVATE);
            SharedPreferences.Editor editor_4 = sharedPref4.edit();
            editor_4.putString(getString(R.string.KEY_HomeMenu), "" + position); // Incrementing the position by 1
            editor_4.commit();

            Log.e(" The Item clicked in the list is ", "" + position);
            ((LaunchActivity_NavDrawer) getActivity()).displayView(position + 1);

        }
    });

    // Removing the edittext for now

    //        final EditText edittext = (EditText) view.findViewById(R.id.editText_search);
    //
    //        edittext.setOnEditorActionListener(
    //                new EditText.OnEditorActionListener() {
    //                    @Override
    //                    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    //
    //
    //
    //                        if (event != null) {
    //                            // if shift key is down, then we want to insert the '\n' char in the TextView;
    //                            // otherwise, the default action is to send the message.
    //
    //                            if (!event.isShiftPressed())
    //                            {
    //                                Log.e(" Enter is pressed! ", "Yes");
    //                                //return true;
    //                                // Start the activity here
    //
    //                            }
    //                            return false;
    //                        }
    //
    //                        Log.e("here we are ", "Yes");
    //
    //                        Intent i = new Intent(getActivity(), LaunchActivity_NavDrawer.class);
    //                        i.putExtra("searchString",edittext.getText().toString());
    //                        i.putExtra("view", "normal");
    //
    //                        SharedPreferences sharedPref4 = getActivity().getSharedPreferences("android_shared", Context.MODE_PRIVATE);
    //                        SharedPreferences.Editor editor_4 = sharedPref4.edit();
    //                        editor_4.putString(getString(R.string.KEY_HomeMenu), "0" ); // Incrementing the position by 1
    //                        editor_4.commit();
    //                        startActivity(i);
    //
    //                        return true;
    //                    }
    //                });

    return view;
}

From source file:com.gh4a.IssueActivity.java

private void fillData() {
    new LoadCommentsTask(this).execute();

    Typeface boldCondensed = getApplicationContext().boldCondensed;

    ListView lvComments = (ListView) findViewById(R.id.list_view);
    // set details inside listview header
    LayoutInflater infalter = getLayoutInflater();
    LinearLayout mHeader = (LinearLayout) infalter.inflate(R.layout.issue_header, lvComments, false);
    mHeader.setClickable(false);//from   w w w  .  ja va  2  s  .c o m

    lvComments.addHeaderView(mHeader, null, false);

    RelativeLayout rlComment = (RelativeLayout) findViewById(R.id.rl_comment);
    if (!isAuthorized()) {
        rlComment.setVisibility(View.GONE);
    }

    TextView tvCommentTitle = (TextView) mHeader.findViewById(R.id.comment_title);
    mCommentAdapter = new CommentAdapter(IssueActivity.this, new ArrayList<Comment>(), mIssue.getNumber(),
            mIssue.getState(), mRepoOwner, mRepoName);
    lvComments.setAdapter(mCommentAdapter);

    ImageView ivGravatar = (ImageView) mHeader.findViewById(R.id.iv_gravatar);
    aq.id(R.id.iv_gravatar).image(GravatarUtils.getGravatarUrl(mIssue.getUser().getGravatarId()), true, false,
            0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

    ivGravatar.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getUser().getLogin(), null);
        }
    });

    TextView tvExtra = (TextView) mHeader.findViewById(R.id.tv_extra);
    TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state);
    TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title);
    TextView tvDescTitle = (TextView) mHeader.findViewById(R.id.desc_title);
    tvDescTitle.setTypeface(getApplicationContext().boldCondensed);
    tvDescTitle.setTextColor(Color.parseColor("#0099cc"));

    tvCommentTitle.setTypeface(getApplicationContext().boldCondensed);
    tvCommentTitle.setTextColor(Color.parseColor("#0099cc"));
    tvCommentTitle
            .setText(getResources().getString(R.string.issue_comments) + " (" + mIssue.getComments() + ")");

    TextView tvDesc = (TextView) mHeader.findViewById(R.id.tv_desc);
    tvDesc.setMovementMethod(LinkMovementMethod.getInstance());

    TextView tvMilestone = (TextView) mHeader.findViewById(R.id.tv_milestone);

    ImageView ivComment = (ImageView) findViewById(R.id.iv_comment);
    if (Gh4Application.THEME == R.style.DefaultTheme) {
        ivComment.setImageResource(R.drawable.social_send_now_dark);
    }
    ivComment.setBackgroundResource(R.drawable.abs__list_selector_holo_dark);
    ivComment.setPadding(5, 2, 5, 2);
    ivComment.setOnClickListener(this);

    tvExtra.setText(mIssue.getUser().getLogin() + "\n" + pt.format(mIssue.getCreatedAt()));
    tvState.setTextColor(Color.WHITE);
    if ("closed".equals(mIssue.getState())) {
        tvState.setBackgroundResource(R.drawable.default_red_box);
        tvState.setText("C\nL\nO\nS\nE\nD");
    } else {
        tvState.setBackgroundResource(R.drawable.default_green_box);
        tvState.setText("O\nP\nE\nN");
    }
    tvTitle.setText(mIssue.getTitle());
    tvTitle.setTypeface(boldCondensed);

    boolean showInfoBox = false;
    if (mIssue.getAssignee() != null) {
        showInfoBox = true;
        TextView tvAssignee = (TextView) mHeader.findViewById(R.id.tv_assignee);
        tvAssignee.setText(mIssue.getAssignee().getLogin() + " is assigned");
        tvAssignee.setVisibility(View.VISIBLE);
        tvAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });

        ImageView ivAssignee = (ImageView) mHeader.findViewById(R.id.iv_assignee);

        aq.id(R.id.iv_assignee).image(GravatarUtils.getGravatarUrl(mIssue.getAssignee().getGravatarId()), true,
                false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

        ivAssignee.setVisibility(View.VISIBLE);
        ivAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });
    }

    if (mIssue.getMilestone() != null) {
        showInfoBox = true;
        tvMilestone.setText(
                getResources().getString(R.string.issue_milestone) + ": " + mIssue.getMilestone().getTitle());
    } else {
        tvMilestone.setVisibility(View.GONE);
    }

    String body = mIssue.getBodyHtml();
    if (!StringUtils.isBlank(body)) {
        HttpImageGetter imageGetter = new HttpImageGetter(this);
        body = HtmlUtils.format(body).toString();
        imageGetter.bind(tvDesc, body, mIssue.getNumber());
    }

    LinearLayout llLabels = (LinearLayout) findViewById(R.id.ll_labels);
    List<Label> labels = mIssue.getLabels();

    if (labels != null && !labels.isEmpty()) {
        showInfoBox = true;
        for (Label label : labels) {
            TextView tvLabel = new TextView(this);
            tvLabel.setSingleLine(true);
            tvLabel.setText(label.getName());
            tvLabel.setTextAppearance(this, R.style.default_text_small);
            tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor()));
            tvLabel.setPadding(5, 2, 5, 2);
            int r = Color.red(Color.parseColor("#" + label.getColor()));
            int g = Color.green(Color.parseColor("#" + label.getColor()));
            int b = Color.blue(Color.parseColor("#" + label.getColor()));
            if (r + g + b < 383) {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
            } else {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_light));
            }
            llLabels.addView(tvLabel);

            View v = new View(this);
            v.setLayoutParams(new LayoutParams(5, LayoutParams.WRAP_CONTENT));
            llLabels.addView(v);
        }
    } else {
        llLabels.setVisibility(View.GONE);
    }

    TextView tvPull = (TextView) mHeader.findViewById(R.id.tv_pull);
    if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) {
        showInfoBox = true;
        tvPull.setVisibility(View.VISIBLE);
        tvPull.setOnClickListener(this);
    }

    if (!showInfoBox) {
        RelativeLayout rl = (RelativeLayout) mHeader.findViewById(R.id.info_box);
        rl.setVisibility(View.GONE);
    }
}

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 ww . j a v a 2 s  . com
    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.earthsea.fish.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*ww w  .j a va 2 s. com*/
 */
protected TextView createDefaultTabView(Context context) {

    //        String activity = context.toString();
    //
    //        Log.v("tab_context",activity);
    //
    TextView textView = new TextView(context);
    //
    //        if (activity.contains("SingleReport")) {

    //            textView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f));

    //        }

    // Instead of messing with layout params maybe we should crank up the padding when we know the
    // number of tab items will be low but we don't want them to be crammed into the view width

    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP);
    textView.setTypeface(Typeface.DEFAULT_BOLD);
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

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

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

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);

    textView.setPadding(40, padding, 40, padding);

    return textView;
}