Example usage for android.widget TextView setText

List of usage examples for android.widget TextView setText

Introduction

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

Prototype

@android.view.RemotableViewMethod
public final void setText(@StringRes int resid) 

Source Link

Document

Sets the text to be displayed using a string resource identifier.

Usage

From source file:com.scigames.registration.Registration5EmailActivity.java

/** Called with the activity is first created. */
@Override/*w  ww .  j  av  a  2  s . co m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "super.OnCreate");

    Intent i = getIntent();
    Log.d(TAG, "getIntent");
    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    studentIdIn = i.getStringExtra("studentId");
    visitIdIn = i.getStringExtra("visitId");
    Log.d(TAG, "...getStringExtra");

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.registration5_email);
    Log.d(TAG, "...setContentView");

    email = (EditText) findViewById(R.id.email);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    // email.setInputType(InputType.TYPE_NULL);
    email.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            //email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
            email.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);
            email.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            email.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });

    Log.d(TAG, "...instantiateEditTexts");

    //display name in greeting sentence
    Resources res = getResources();
    TextView greets = (TextView) findViewById(R.id.greeting);
    greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn));
    Log.d(TAG, greets.toString());
    Log.d(TAG, "...Greetings");

    // Hook up button presses to the appropriate event handler.
    //((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);
    Log.d(TAG, "...instantiateButtons");

    //set listener
    task.setOnResultsListener(this);
}

From source file:com.fastbootmobile.twofactorauthdemo.MainActivity.java

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

    setContentView(R.layout.info_layout);

    Button regButton = (Button) findViewById(R.id.register);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        if (extras.getString("otp", null) != null) {
            TextView txt = (TextView) findViewById(R.id.txt);
            regButton.setVisibility(View.GONE);
            txt.setText("One Time Password :  " + extras.getString("otp", null));
            return;
        }/* ww  w  .ja v a 2  s  .  c  o  m*/
    }

    mReg = new OwnPushRegistrant(this);
    mHandler = new Handler();
    receiver = new RegisterReceiver(new Handler());

    IntentFilter filter = new IntentFilter(OwnPushClient.INTENT_REGISTER);
    filter.addCategory(BuildConfig.APP_PUBLIC_KEY);

    registerReceiver(receiver, filter);

    final SharedPreferences prefs = this.getApplicationContext().getSharedPreferences(OwnPushClient.PREF_PUSH,
            Context.MODE_PRIVATE);

    if (!prefs.getBoolean(OwnPushClient.PREF_REG_DONE, false)) {

        regButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                OwnPushCrypto fp = new OwnPushCrypto();
                OwnPushCrypto.AppKeyPair keys = fp.generateInstallKey();

                boolean ret = mReg.register(BuildConfig.APP_PUBLIC_KEY, keys.getPublicKey());

                if (ret) {
                    //STORE THEM
                    prefs.edit().putString(OwnPushClient.PREF_PUBLIC_KEY, keys.getPublicKey()).commit();
                    prefs.edit().putString(OwnPushClient.PREF_PRIVATE_KEY, keys.getPrivateKey()).commit();
                }
            }
        });
    } else {
        regButton.setVisibility(View.GONE);

        updateUI();

        if (prefs.getString("device_uid", null) == null) {
            registerWithBackend();
        }
    }

}

From source file:net.olejon.mdapp.LvhAdapter.java

@Override
public void onBindViewHolder(CategoryViewHolder viewHolder, int i) {
    try {/*from  w  w  w.  j a  va 2  s .  com*/
        final String color;
        final String icon;

        final JSONObject categoriesJsonObject = mCategories.getJSONObject(i);

        switch (i) {
        case 0: {
            color = "#F44336";
            icon = "lvh_urgent";

            viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.red));
            viewHolder.icon.setImageResource(R.drawable.ic_favorite_white_24dp);

            break;
        }
        case 1: {
            color = "#9C27B0";
            icon = "lvh_symptoms";

            viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.purple));
            viewHolder.icon.setImageResource(R.drawable.ic_stethoscope);

            break;
        }
        case 2: {
            color = "#FF9800";
            icon = "lvh_injuries";

            viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.orange));
            viewHolder.icon.setImageResource(R.drawable.ic_healing_white_24dp);

            break;
        }
        case 3: {
            color = "#009688";
            icon = "lvh_administrative";

            viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.teal));
            viewHolder.icon.setImageResource(R.drawable.ic_my_library_books_white_24dp);

            break;
        }
        default: {
            color = "#009688";
            icon = "lvh_administrative";

            viewHolder.card.setCardBackgroundColor(mContext.getResources().getColor(R.color.teal));
            viewHolder.icon.setImageResource(R.drawable.ic_my_library_books_white_24dp);
        }
        }

        viewHolder.title.setText(categoriesJsonObject.getString("title"));

        viewHolder.categories.removeAllViews();

        final JSONArray categoriesJsonArray = categoriesJsonObject.getJSONArray("categories");

        for (int f = 0; f < categoriesJsonArray.length(); f++) {
            final JSONObject categoryJsonObject = categoriesJsonArray.getJSONObject(f);

            final String title = categoryJsonObject.getString("title");
            final String subcategories = categoryJsonObject.getString("subcategories");

            TextView textView = (TextView) mLayoutInflater.inflate(R.layout.activity_lvh_card_categories_item,
                    null);
            textView.setText(categoryJsonObject.getString("title"));

            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(mContext, LvhCategoriesActivity.class);
                    intent.putExtra("color", color);
                    intent.putExtra("icon", icon);
                    intent.putExtra("title", title);
                    intent.putExtra("subcategories", subcategories);
                    mContext.startActivity(intent);
                }
            });

            viewHolder.categories.addView(textView);
        }

        animateView(viewHolder.card, i);
    } catch (Exception e) {
        Log.e("LvhAdapter", Log.getStackTraceString(e));
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LinkObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from  w w  w.j a v  a 2 s  . c  o  m*/
    TextView valueTV = new TextView(context);
    String title;
    if (content.has(TITLE)) {
        title = "Link: " + content.optString(TITLE);
    } else {
        title = content.optString(URI);
    }
    valueTV.setText(title);
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    if (Linkify.addLinks(valueTV, Linkify.ALL)) {
        if (!allowInteractions)
            valueTV.setMovementMethod(null);
    }

    frame.addView(valueTV);
}

From source file:com.krayzk9s.imgurholo.ui.AccountFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    Log.d("Username", username);
    ImgurHoloActivity activity = (ImgurHoloActivity) getActivity();
    SharedPreferences settings = activity.getApiCall().settings;
    Log.d("SettingTitle", username);
    View view = inflater.inflate(R.layout.account_layout, container, false);
    mPullToRefreshLayout = (PullToRefreshLayout) view.findViewById(R.id.ptr_layout);
    ActionBarPullToRefresh.from(getActivity())
            // Mark All Children as pullable
            .allChildrenArePullable()/* w  w w. j  a  va2s  .  com*/
            // Set the OnRefreshListener
            .listener(this)
            // Finally commit the setup to our PullToRefreshLayout
            .setup(mPullToRefreshLayout);
    LinearLayout header = (LinearLayout) view.findViewById(R.id.header);
    if (settings.getString("theme", MainActivity.HOLO_LIGHT).equals(MainActivity.HOLO_LIGHT))
        header.setBackgroundColor(0xFFCCCCCC);
    biography = (TextView) view.findViewById(R.id.biography);
    TextView usernameText = (TextView) view.findViewById(R.id.username);
    usernameText.setText(username);
    created = (TextView) view.findViewById(R.id.created);
    reputation = (TextView) view.findViewById(R.id.reputation);
    mDrawerList = (ListView) view.findViewById(R.id.account_list);
    mMenuList = getResources().getStringArray(R.array.accountMenu);
    adapter = new ArrayAdapter<String>(view.getContext(), R.layout.drawer_list_item, mMenuList);
    mDrawerList.setAdapter(adapter);
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    if (savedInstanceState == null) {
        getAccount();
    }
    return view;
}

From source file:com.restswitch.controlpanel.MainActivity.java

public void setProgressBars(String pb1Text, int pb1Pos, String pb2Text, int pb2Pos) {
    ProgressBar pb = (ProgressBar) findViewById(R.id.progressBar);
    pb.setProgress(pb1Pos);/* ww w .java  2 s. c  om*/
    pb.setSecondaryProgress(pb2Pos);

    TextView tv1 = (TextView) findViewById(R.id.progressBarText);
    tv1.setText(pb1Text);

    TextView tv2 = (TextView) findViewById(R.id.secondaryProgressBarText);
    tv2.setText(pb2Text);

    int pbwTot = pb.getWidth();
    int pbw1 = ((pbwTot * pb1Pos) / 100);
    tv1.setWidth(pbw1);

    pbw1 += 96;
    int pbw2 = (pbwTot - pbw1);
    ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) tv2.getLayoutParams();
    mlp.setMargins(pbw1, 2, 0, 0);
    tv2.setWidth(pbw2);
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE TITLE ROW/*www  . j av a2 s.  co m*/
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleTitleRow(Map<String, String> att, LinearLayout linear) {
    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setMinimumHeight(30);
    container_layout
            .setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo_blue));
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value_params);

    LinearLayout.LayoutParams ltext1 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView t1 = new TextView(context);
    t1.setText(att.get("value"));
    t1.setTextSize(11);
    t1.setGravity(Gravity.CENTER_HORIZONTAL);
    t1.setPadding(2, 0, 0, 2);
    t1.setTextColor(Color.rgb(255, 255, 255));
    container_layout.addView(t1, ltext1);

    linear.addView(container_layout);
    return linear;
}

From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java

/**
 * SINGLE IMAGE ROW/*  w w w  . j  a  va 2 s  . com*/
 * @param att
 * @param linear
 * @return
 */
public LinearLayout getSingleImageRow(Map<String, String> att, LinearLayout linear) {

    LinearLayout container_layout = new LinearLayout(context);
    container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo));
    container_layout.setMinimumHeight(46);
    container_layout.setVerticalGravity(Gravity.CENTER);

    LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    TextView tx = new TextView(context);
    tx.setText(att.get("title"));
    tx.setTextSize(11);
    tx.setTypeface(null, Typeface.BOLD);
    tx.setGravity(Gravity.LEFT);
    tx.setPadding(3, 0, 0, 2);
    tx.setTextColor(Color.rgb(66, 66, 66));
    container_layout.addView(tx, value);

    LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 40, 0.5f);
    ImageView img = new ImageView(context);
    String path = "it.redturtle.mobile.apparpav:drawable/" + FilenameUtils.removeExtension(att.get("value"));
    img.setImageResource(context.getResources().getIdentifier(path, null, null));
    img.setPadding(0, 3, 0, 3);
    container_layout.addView(img, value_params);

    linear.addView(container_layout);
    return linear;
}

From source file:gov.wa.wsdot.android.wsdot.ui.BlogFragment.java

public void onLoadFinished(Loader<ArrayList<BlogItem>> loader, ArrayList<BlogItem> data) {

    if (!data.isEmpty()) {
        mAdapter.setData(data);//from   w ww  . j a v  a 2  s  . c  om
    } else {
        TextView t = (TextView) mEmptyView;
        t.setText(R.string.no_connection);
        getListView().setEmptyView(mEmptyView);
    }

    swipeRefreshLayout.setRefreshing(false);
}