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:com.alibaba.akita.samples.TestFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if ((savedInstanceState != null) && savedInstanceState.containsKey(KEY_CONTENT)) {
        mContent = savedInstanceState.getString(KEY_CONTENT);
    }//from w  w w . j  a v  a2 s. co m

    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);
    text.setPadding(20, 20, 20, 20);

    LinearLayout layout = new LinearLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setGravity(Gravity.CENTER);
    layout.addView(text);

    return layout;
}

From source file:am.project.x.business.widgets.tagtabstrip.TagTabStripActivity.java

private ArrayList<View> getPagers() {
    ArrayList<View> views = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
        TextView text = new TextView(this);
        text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180);
        text.setText(String.format(Locale.getDefault(), "%d", i + 1));
        text.setGravity(Gravity.CENTER);
        text.setTextColor(0xff000000);/*from  w w  w. j a v  a2  s . c  om*/
        views.add(text);
    }
    return views;
}

From source file:com.ternup.caddisfly.widget.FormWidget.java

public FormWidget(Context context, String name) {
    _layout = new LinearLayout(context);
    //_layout.setLayoutParams( FormActivity.defaultLayoutParams );
    _layout.setOrientation(LinearLayout.VERTICAL);

    _property = name;/*from w  ww  .  j  a va  2s  .c  o  m*/
    _displayText = name.replace("_", " ");
    _displayText = toTitleCase(_displayText);

    _label = new TextView(context);
    _label.setText(getDisplayText());
    _label.setTextSize(context.getResources().getDimension(R.dimen.labelTextSize));

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);

    params.bottomMargin = 0;
    params.topMargin = 10;

    _label.setLayoutParams(params);
    _label.setAllCaps(true);
    _label.setTextColor(context.getResources().getColor(R.color.labelTextColor));
    _layout.addView(_label);

}

From source file:com.amazonaws.demo.messageboard.MessageQueueAdapter.java

public View getView(int pos, View convertView, ViewGroup parent) {
    TextView messageText = new TextView(parent.getContext());
    messageText.setText(this.getMessageText(pos));
    messageText.setGravity(Gravity.LEFT);
    messageText.setPadding(10, 10, 10, 10);
    messageText.setMaxWidth(200);/*from w  w w .  j ava2s  .c o  m*/
    messageText.setMinWidth(200);
    messageText.setTextSize(16);

    return messageText;
}

From source file:com.example.android.networkconnect.SimpleTextFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Before initializing the textView, check if any arguments were provided via setArguments.
    processArguments();/*from   w w w. j  av  a  2  s . c  o m*/

    // Create a new TextView and set its text to whatever was provided.
    mTextView = new TextView(getActivity());
    mTextView.setGravity(Gravity.CENTER);

    if (mText != null) {
        mTextView.setText(mText);
        Log.i("SimpleTextFragment", mText);
    }
    return mTextView;
}

From source file:am.project.x.business.widgets.indicatortabstrip.IndicatorTabStripActivity.java

private ArrayList<View> getPagers() {
    ArrayList<View> views = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        TextView text = new TextView(this);
        text.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 180);
        text.setText(String.format(Locale.getDefault(), "%d", i + 1));
        text.setGravity(Gravity.CENTER);
        text.setTextColor(0xff000000);//from w  w  w.j a  va 2s . co  m
        views.add(text);
    }
    return views;
}

From source file:cn.yunt.www.pagerslidingtabstrip.SuperAwesomeCardFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//from  ww  w  .  j  av a2s .  c o  m

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD " + (position + 1));

    fl.addView(v);
    return fl;
}

From source file:com.codewarrior.mobiocontact.fragments.DialerFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);//ww  w  .  j  av a 2s.  c  o m

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD 44");

    fl.addView(v);
    return fl;
}

From source file:com.codewarrior.mobiocontact.fragments.RecentFragment.java

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

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    FrameLayout fl = new FrameLayout(getActivity());
    fl.setLayoutParams(params);/*from   w ww.j  a  v a  2  s  .  com*/

    final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());

    TextView v = new TextView(getActivity());
    params.setMargins(margin, margin, margin, margin);
    v.setLayoutParams(params);
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER);
    v.setBackgroundResource(R.drawable.background_card);
    v.setText("CARD 22");

    fl.addView(v);
    return fl;
}

From source file:eu.thecoder4.gpl.pleftdroid.HandleLinksActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TextView tv = new TextView(this);

    tv.setText("Verifying Link...");
    setContentView(tv);/*from w  w w  . jav  a 2 s .c o m*/

    Intent intent = getIntent();
    if (intent.getAction().equals("android.intent.action.VIEW")) {
        try {
            Uri uri = getIntent().getData();
            theurl = uri.toString();

        } catch (Exception e) {
            Toast.makeText(this, R.string.toast_couldnotopenurl, Toast.LENGTH_LONG).show();
        }
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {

        Bundle extras = intent.getExtras();
        theurl = extras.getCharSequence(Intent.EXTRA_TEXT).toString();
    } else {
        theurl = "";
    }
    //Toast.makeText(this, "The URL  =  "+theurl, Toast.LENGTH_LONG).show();

    // Parse the URL
    // VERIFICATION: verify?id=&u=&p=
    // INVITATION: a?id=&u=&p=
    if (theurl.indexOf("?") < 0 && theurl.indexOf("/verify?") < 0 && theurl.indexOf("/a?") < 0) {
        Toast.makeText(this, R.string.toast_linknotsupp, Toast.LENGTH_LONG).show();
        finish();
    } else {
        Map<String, String> arr = PleftBroker.getParamsFromURL(theurl);

        pserver = arr.get("pserver");
        if (arr.get("id") != null) {
            aid = Integer.parseInt(arr.get("id"));
        } else {
            aid = 0;
        }
        vcode = arr.get("p");
        user = arr.get("u");
        if (aid == 0 || vcode == null || user == null) {
            Toast.makeText(this, R.string.toast_shlinknotvalid, Toast.LENGTH_LONG).show();
            finish();
        } else { // we have a valid Link

            handleLnk = new Runnable() {
                @Override
                public void run() {
                    handleLink();
                }
            };
            Thread thread = new Thread(null, handleLnk, "Handlethrd");
            thread.start();
        } // End - if Link is Valid
    }
}