Example usage for android.widget TextView TextView

List of usage examples for android.widget TextView TextView

Introduction

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

Prototype

public TextView(Context context) 

Source Link

Usage

From source file:Main.java

private static TableRow generateAfiTblRow(Context context, String first, String second) {
    TableRow tr = new TableRow(context);
    tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    LayoutParams childLp = new LayoutParams(0, LayoutParams.FILL_PARENT, 1);

    TextView amount = new TextView(context);
    amount.setText(first);//  ww w .j a  va 2  s  .  com
    amount.setGravity(Gravity.CENTER);
    tr.addView(amount, childLp);

    TextView score = new TextView(context);
    score.setText(second);
    score.setGravity(Gravity.CENTER);
    tr.addView(score, childLp);

    return tr;
}

From source file:cc.softwarefactory.lokki.android.fragments.HelpFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    TextView textView = new TextView(getActivity());
    textView.setPadding(15, 15, 15, 15);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    ScrollView scroller = new ScrollView(getActivity());
    scroller.addView(textView);/*from w  w w  .jav a  2 s. c  om*/

    return scroller;
}

From source file:cn.foxnickel.listentome.view.ViewUtil.java

public static View getWordsView(Context context, String word, @ColorRes int color, boolean isTextSelectable) {
    TextView tv = new TextView(context);
    tv.setTextColor(ContextCompat.getColor(context, color));
    tv.setPadding(0, 6, 0, 6);/*from   w  w w  . j a  v  a2s .  c om*/
    tv.setTextSize(16);
    tv.setTextIsSelectable(isTextSelectable);
    tv.setGravity(Gravity.LEFT);
    tv.setText(word);
    return tv;
}

From source file:com.google.zxing.client.android.TestActivity.java

@Override
protected void onCreate(Bundle savedBundleInstance) {
    super.onCreate(savedBundleInstance);
    TextView tv = new TextView(this);
    tv.setText(getIntent().getStringExtra("test"));
    setContentView(tv);//w w  w  .ja v a  2s  . c  o  m
}

From source file:com.jamesgiang.aussnowcam.Utils.java

public static void About(Context c) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(c);
    dialogBuilder.setTitle(R.string.app_name);
    dialogBuilder.setIcon(R.drawable.icon);
    TextView textView = new TextView(c);
    SpannableString s = new SpannableString(c.getString(R.string.about_info));
    Linkify.addLinks(s, Linkify.WEB_URLS);
    textView.setText(s);/*w ww .j  av a 2 s .c  o m*/
    textView.setGravity(Gravity.CENTER);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    dialogBuilder.setView(textView);
    dialogBuilder.show();
}

From source file:com.contralabs.inmap.fragments.LegalNoticesDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();

    ScrollView scrollView = new ScrollView(context);
    // Set up the TextView
    final TextView message = new TextView(context);
    // We'll use a spannablestring to be able to make links clickable
    final SpannableString s = new SpannableString(
            GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(context));

    // Set some padding
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());
    message.setPadding(padding, padding, padding, padding);
    // Set up the final string
    message.setText(s);/* w ww . j a va2 s  . c o m*/
    scrollView.addView(message);
    // Now linkify the text
    Linkify.addLinks(message, Linkify.ALL);
    Linkify.addLinks(message, Pattern.compile("@([A-Za-z0-9_-]+)"), "https://twitter.com/#!/");
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.legal_notices).setCancelable(true)
            .setIcon(R.drawable.ic_launcher)
            .setPositiveButton(context.getString(R.string.voltar), (OnClickListener) null).setView(scrollView)
            .create();
}

From source file:ar.rulosoft.mimanganu.LicenseFragment.java

@Nullable
@Override/*from ww w. ja v a2s. co  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    setHasOptionsMenu(true);
    setRetainInstance(true);
    mLicenseView = new TextView(getActivity());
    //        mLicenseView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Medium);
    mLicenseView.setPadding(10, 10, 10, 10);
    if (!MainActivity.darkTheme) {
        mLicenseView.setTextColor(ContextCompat.getColor(getContext(), black));
    }
    ScrollView newScroll = new ScrollView(getActivity());
    newScroll.addView(mLicenseView);
    return newScroll;
}

From source file:com.yonisamlan.android.metaqr.AttributionsActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView textView = new TextView(this);
    setContentView(textView);/*  w  w  w. j a  v  a2s .c om*/
    String html;

    try {
        html = IOUtils.toString(getResources().openRawResource(R.raw.licenses));
    } catch (NotFoundException e) {
        e.printStackTrace();
        html = "Error reading license.";
    } catch (IOException e) {
        e.printStackTrace();
        html = "Error reading license.";
    }

    textView.setText(Html.fromHtml(html));
    textView.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:ca.rmen.android.scrumchatter.chart.ChartUtils.java

static void addLegendEntry(Context context, ViewGroup legendView, String name, int color) {
    TextView memberLegendEntry = new TextView(context);
    memberLegendEntry.setText(name);//from   w  w w.  ja  v a2  s  .  c  o m
    memberLegendEntry.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    memberLegendEntry.setPadding(0, 0,
            context.getResources().getDimensionPixelSize(R.dimen.chart_legend_entry_padding), 0);

    final Drawable icon;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square);
        memberLegendEntry.setTextColor(color);
    } else {
        icon = ContextCompat.getDrawable(context, R.drawable.ic_legend_square).mutate();
        DrawableCompat.setTint(icon, color);
    }
    memberLegendEntry.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
    legendView.addView(memberLegendEntry);
}

From source file:com.benli.testdagger2.ui.HomeFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    TextView tv = new TextView(getActivity());
    tv.setGravity(CENTER);//  ww  w. j  av a  2 s  .c  o  m
    tv.setText("Hello, World");
    return tv;
}