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.groupme.sdk.activity.PinEntryActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_pinentry);

    TextView pinEntryInstructions = (TextView) findViewById(R.id.pin_entry_instructions);
    pinEntryInstructions
            .setText(getString(R.string.pin_entry_instructions, getIntent().getStringExtra("phone_number")));

    mNameEntry = (EditText) findViewById(R.id.name_entry);
    mPinEntry = (EditText) findViewById(R.id.pin_entry);
    mAlternateButton = (Button) findViewById(R.id.not_number_button);

    SpannableString str = new SpannableString(getString(R.string.link_not_number));
    str.setSpan(new UnderlineSpan(), 0, str.length(), 0);
    mAlternateButton.setText(str);//from ww  w .j ava 2  s  .  c  om
}

From source file:com.motelabs.chromemote.bridge.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SharedPreferences prefs = this.getSharedPreferences("com.motelabs.chromemote.bridge", Context.MODE_PRIVATE);
    boolean isActive = prefs.getBoolean("com.motelabs.chromemote.bridge.active", true);

    TextView ipAddressTextView = (TextView) findViewById(R.id.ipAddressTextView);
    ipAddressTextView.setText(getLocalIpAddress());

    backgroundServiceIntent = new Intent(this, BackgroundService.class);

    if (isActive)
        initBackgroundService();/*w ww  . j  a v a  2s . co  m*/
    else {
        serviceEnabled = false;
        //unloadBackgroundService();

        TextView serviceStatusTextView = (TextView) findViewById(R.id.serviceStatusTextView);
        serviceStatusTextView.setText("INACTIVE");

        ImageButton toggleServiceButton = (ImageButton) findViewById(R.id.toggleServiceButton);
        toggleServiceButton.setBackgroundResource(R.drawable.toggled_off_btn);
    }
}

From source file:com.liferay.tasks.activity.AddTaskActivity.java

protected void initialize(Bundle extras) {
    if (extras == null) {
        return;/*from w w  w.  j  a v  a  2 s.  c om*/
    }

    _update = extras.getBoolean(EXTRA_UPDATE, false);
    _task = (TaskModel) extras.getSerializable(EXTRA_TASK);

    if (!_update) {
        return;
    }

    View container = findViewById(R.id.status_bar_container);
    container.setVisibility(View.VISIBLE);

    int progress = _task.getStatus() - 1;
    TextView percentageView = (TextView) findViewById(R.id.percentage);
    percentageView.setText(String.valueOf(progress * 20) + "%");

    OnStatusChangedListener listener = new OnStatusChangedListener(percentageView);

    _titleView.setText(_task.getTitle());
    _seekBar.setProgress(progress);
    _seekBar.setOnSeekBarChangeListener(listener);
}

From source file:de.vakuumverpackt.foul.About.java

@Override
public void onCreate(final Bundle bundle) {
    setContentView(R.layout.activity_about);

    TextView text = (TextView) findViewById(R.id.textView);
    text.setLinkTextColor(getLinkColor());
    text.setMovementMethod(LinkMovementMethod.getInstance());
    text.setText(getText());
    text.setTextColor(getTextColor());//from ww w. ja  v a 2 s  .  c  o m
}

From source file:com.springsource.greenhouse.events.sessions.EventSessionDetailsActivity.java

private void refreshEventDetails() {
    if (session == null) {
        return;//from   w w w  . j  a  va  2s .  c o  m
    }

    TextView t = (TextView) findViewById(R.id.event_session_details_name);
    t.setText(session.getTitle());

    t = (TextView) findViewById(R.id.event_session_details_leaders);
    t.setText(session.getJoinedLeaders(", "));

    t = (TextView) findViewById(R.id.event_session_details_time_and_room);
    t.setText(session.getFormattedTimeSpan() + " in " + session.getRoom().getLabel());

    t = (TextView) findViewById(R.id.event_session_details_rating);
    if (session.getRating() == 0) {
        t.setText("No Ratings");
    } else {
        t.setText(session.getRating() + " Stars");
    }

    t = (TextView) findViewById(R.id.event_session_details_description);
    t.setText(session.getDescription());

    setFavoriteStatus(session.isFavorite());
}

From source file:com.motelabs.chromemote.bridge.MainActivity.java

public void toggleServiceEnabled(View view) {
    if (!serviceEnabled) {
        serviceEnabled = true;/*from   w ww .  j ava  2  s. com*/
        initBackgroundService();

        TextView serviceStatusTextView = (TextView) findViewById(R.id.serviceStatusTextView);
        serviceStatusTextView.setText("ACTIVE");

        ImageButton toggleServiceButton = (ImageButton) findViewById(R.id.toggleServiceButton);
        toggleServiceButton.setBackgroundResource(R.drawable.toggled_on_btn);

    } else {
        serviceEnabled = false;
        unloadBackgroundService();

        TextView serviceStatusTextView = (TextView) findViewById(R.id.serviceStatusTextView);
        serviceStatusTextView.setText("INACTIVE");

        ImageButton toggleServiceButton = (ImageButton) findViewById(R.id.toggleServiceButton);
        toggleServiceButton.setBackgroundResource(R.drawable.toggled_off_btn);
    }
}

From source file:eu.operando.proxy.wifi.AccessPointsDetail.java

public void setView(@NonNull Resources resources, @NonNull View view, @NonNull final WiFiDetail wiFiDetail) {

    TextView ssidLabel = (TextView) view.findViewById(R.id.ssid);
    ssidLabel.setText(wiFiDetail.getTitle());
    TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed);
    String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress();
    boolean isConnected = StringUtils.isNotBlank(ipAddress);
    if (!isConnected) {
        textLinkSpeed.setVisibility(View.GONE);
        ssidLabel.setTextColor(resources.getColor(android.R.color.white));
    } else {/*  w  w  w .j  a  va 2 s .  co  m*/
        ssidLabel.setTextColor(resources.getColor(R.color.connected));

        int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed();
        if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) {
            textLinkSpeed.setVisibility(View.GONE);
        } else {
            textLinkSpeed.setVisibility(View.VISIBLE);
            textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS));
        }
    }

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();
    ImageView imageView = (ImageView) view.findViewById(R.id.levelImage);
    imageView.setImageResource(strength.imageResource());
    imageView.setColorFilter(resources.getColor(strength.colorResource()));

    Security security = wiFiDetail.getSecurity();
    ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage);
    securityImage.setImageResource(security.imageResource());
    securityImage.setColorFilter(resources.getColor(R.color.icons_color));

    TextView textLevel = (TextView) view.findViewById(R.id.level);
    textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel()));
    textLevel.setTextColor(resources.getColor(strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel))
            .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel()));
    ((TextView) view.findViewById(R.id.frequency))
            .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS));
    ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance()));
    ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities());

    LayoutInflater layoutInflater = mainContext.getLayoutInflater();

    final WiFiApConfig wiFiApConfig = wiFiDetail.getWiFiAdditional().getWiFiApConfig();
    ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage);
    if (wiFiApConfig != null) {

        configuredImage.setVisibility(View.VISIBLE);

        if (isOperandoCompatible(wiFiApConfig)) {
            configuredImage.setColorFilter(resources.getColor(android.R.color.holo_green_light));
            view.setOnClickListener(
                    new ConfiguredClickListener(context, wiFiDetail, wiFiApConfig, isConnected));
        } else {
            configuredImage.setColorFilter(resources.getColor(android.R.color.holo_red_light));
            view.setOnClickListener(new ForgetClickListener(context, wiFiDetail));
        }

    } else {
        configuredImage.setVisibility(View.GONE);
        view.setOnClickListener(new ConnectClickListener(context, wiFiDetail, layoutInflater));
    }

}

From source file:com.yasiradnan.Schedule.ScheduleMainActivity.java

public void updatePageDate(int position) {
    TextView dayView = ((TextView) findViewById(R.id.tvDay));
    dayView.setText(data[position][0].getDate());
}

From source file:com.aegiswallet.actions.CurrencyActivity.java

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

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getActionBar().setCustomView(R.layout.aegis_send_actionbar);

    TextView titleTextView = (TextView) findViewById(R.id.action_bar_title_text);
    titleTextView.setText(getString(R.string.currencies_activity_label));

    ImageButton backButton = (ImageButton) findViewById(R.id.action_bar_icon_back);
    backButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from w  w  w  . ja v a  2s.co  m*/
        public void onClick(View view) {
            Intent openMainActivity = new Intent(context, MainActivity.class);
            openMainActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            context.startActivity(openMainActivity);
            finish();
        }
    });

    ArrayList<CurrencyPojo> currencies = new ArrayList<CurrencyPojo>();

    JSONObject jsonObject = BasicUtils.parseJSONData(getApplicationContext(),
            Constants.BLOCKCHAIN_CURRENCY_FILE_NAME);

    if (jsonObject != null) {

        Iterator i = jsonObject.keys();
        while (i.hasNext()) {

            try {
                String currency = (String) i.next();
                JSONObject detailObj = jsonObject.getJSONObject(currency);
                CurrencyPojo newPojo = new CurrencyPojo(currency, detailObj.getDouble("last"),
                        detailObj.getString("symbol"));

                currencies.add(newPojo);
            } catch (JSONException e) {
                Log.e("Currency Activity", "JSON Exception " + e.getMessage());
            }
        }

        String currentCurrency = prefs.getString(Constants.CURRENCY_PREF_KEY, null);
        CurrencyPojo firstPojo = currencies.get(0);

        for (int j = 0; j < currencies.size(); j++) {
            CurrencyPojo pojo = currencies.get(j);
            if (pojo.getCurrency().equals(currentCurrency)) {
                currencies.set(0, pojo);
                currencies.set(j, firstPojo);
            }
        }

    }

    CurrencyAdapter currencyAdapter = new CurrencyAdapter(this, R.layout.currency_list_item, currencies, prefs);

    ListView transactionListView = (ListView) findViewById(R.id.currency_list);
    transactionListView.setAdapter(currencyAdapter);

}

From source file:com.test.shopping.view.ProductDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    /*/*from   ww w . ja va 2  s.c o  m*/
     * Inflate the layout based on the current product details.
     * Fetch the product associated with the current position in product id list
     */
    ProductDataModel product = CacheUtil.getInstance(getActivity()).getProduct(mPosition);

    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.product_detail, container, false);

    TextView productName = (TextView) rootView.findViewById(R.id.product_name);
    productName.setText(StringEscapeUtils.unescapeJava(product.getProductName()));

    String longDes = product.getLongDescription();
    TextView longDescLabel = (TextView) rootView.findViewById(R.id.long_description_label);
    TextView longDesc = (TextView) rootView.findViewById(R.id.long_description);
    if (longDes != null && longDes.length() > 0) {
        longDesc.setText(Jsoup.clean(longDes, Whitelist.simpleText()));
        longDesc.setVisibility(View.VISIBLE);
        longDescLabel.setVisibility(View.VISIBLE);
    } else {
        longDesc.setVisibility(View.INVISIBLE);
        longDescLabel.setVisibility(View.INVISIBLE);
    }

    TextView price = (TextView) rootView.findViewById(R.id.price);
    price.setText(product.getPrice());

    ImageView imageView = (ImageView) rootView.findViewById(R.id.image);
    ImageLoader loader = ConnectionUtil.getInstance(sContext).getImageLoader();
    loader.get(product.getProductImage(),
            ImageLoader.getImageListener(imageView, R.mipmap.ic_launcher, R.mipmap.ic_launcher));

    TextView ratingCountView = (TextView) rootView.findViewById(R.id.rating_count);

    ratingCountView.setText("(" + String.valueOf(product.getReviewCount() + ")"));

    RatingBar bar = (RatingBar) rootView.findViewById(R.id.ratingBar);

    bar.setRating((int) product.getReviewRating());
    bar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    TextView inStock = (TextView) rootView.findViewById(R.id.inStock);
    if (product.isInStock()) {
        inStock.setTextColor(getResources().getColor(android.R.color.holo_green_dark));
        inStock.setText(R.string.in_stock_label);
    } else {
        inStock.setTextColor(getResources().getColor(android.R.color.holo_red_dark));
        inStock.setText(R.string.out_of_stock_label);
    }

    return rootView;
}