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.g_node.gca.map.MapActivity.java

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

    getActionBar().setIcon(getResources().getDrawable(R.drawable.icon_maps));
    getActionBar().setTitle("Locations Map");

    getActionBar().setDisplayHomeAsUpEnabled(true);

    try {//from  w  w  w.j  av  a2 s. com
        MapsInitializer.initialize(this);
    } catch (GooglePlayServicesNotAvailableException e) {
        e.printStackTrace();
    }
    locationMarkers();

    //Lisener for infoWindow to get LAT & LONG of that marker
    supportMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {

        public void onInfoWindowClick(Marker marker) {
            LatLng position = marker.getPosition();
            Log.i(gtag, "Marker Info Clicked - LAT: " + position.latitude + ", LONG: " + position.longitude);

            Intent navigateIntent = new Intent(Intent.ACTION_VIEW);

            String currentLat = String.valueOf(position.latitude);
            String currentLong = String.valueOf(position.longitude);
            String currLabel = marker.getTitle();

            String geoLocation = "geo:0,0?q=" + currentLat + "," + currentLong + "(" + currLabel + ")";
            navigateIntent.setData(Uri.parse(geoLocation));
            startActivity(navigateIntent);

        }
    });

    //adapter for custom info-window - added icon for navigation
    supportMap.setInfoWindowAdapter(new InfoWindowAdapter() {

        @Override
        public View getInfoWindow(Marker arg0) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public View getInfoContents(Marker arg0) {
            // TODO Auto-generated method stub
            // Getting view from the layout file info_window_layout
            View v = getLayoutInflater().inflate(R.layout.info_window_layout, null);

            // Getting reference to the TextView to set title
            TextView note = (TextView) v.findViewById(R.id.note);

            note.setText(arg0.getTitle());

            // Returning the view containing InfoWindow contents
            return v;
        }
    });

}

From source file:com.blueverdi.rosietheriveter.PhotoViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle b = getIntent().getExtras();//from  w w w  . j a  va  2  s. c  o m
    try {
        details = b.getParcelable(SiteDetails.PARCEL_NAME);
    } catch (Exception e) {
        MyLog.d(TAG, "exception retrieving site info");
        finish();
    }
    if (details == null) {
        MyLog.d(TAG, "no details");
        finish();
    }
    setContentView(R.layout.activity_photo_view);
    View view = findViewById(R.id.photoView);
    view.setOnTouchListener(new OnSwipeTouchListener(this) {
        @Override
        public void onSwipeLeft() {
            nextPhoto();
        }

        @Override
        public void onSwipeRight() {
            lastPhoto();
        }

        @Override
        public void onTap() {
            zoomIn();
        }
    });
    view = findViewById(R.id.leftArrow);
    view.setOnClickListener(this);
    view = findViewById(R.id.rightArrow);
    view.setOnClickListener(this);
    TextView tv = (TextView) findViewById(R.id.name);
    tv.setText(details.name);
    caption = (TextView) findViewById(R.id.caption);
    photoView = (ImageView) findViewById(R.id.photoView);
    imageSource = PHOTO_BASE + File.separator + details.photoDirectory;
    try {
        imageFiles = this.getAssets().list(imageSource);
    } catch (Exception e) {
        MyLog.d(TAG, e.toString());
        e.printStackTrace();
        imageFiles = new String[0];
    }
    if (imageFiles.length == 0) {
        MyLog.d(TAG, "no photos to display");
        finish();
    }
    captions = getResources().getStringArray(details.captionArrayID);
    if (savedInstanceState != null) {
        index = savedInstanceState.getInt(INDEX);
    }
    displayImage(index);
    rosieHelpMenu = new RosieHelpMenu(this);
    hintScreen();
}

From source file:com.hybris.mobile.app.commerce.helper.OrderHelper.java

/**
 * Populate the order summary//w  ww .j a  va 2s.c o m
 *
 * @param order
 */
public static void createOrderSummary(Activity activity, Order order) {

    LinearLayout mOrderSummaryItemsLayout;
    TextView mOrderSummaryItems;
    TextView mOrderSummarySubtotal;
    TextView mOrderSummarySavings;
    TextView mOrderSummaryTax;
    TextView mOrderSummaryShipping;
    TextView mOrderSummaryTotal;
    TextView mOrderSummaryPromotion;
    TableRow mOrderSummarySavingsRow;

    // order summary
    mOrderSummaryItemsLayout = (LinearLayout) activity.findViewById(R.id.order_summary_items_layout);
    mOrderSummaryItems = (TextView) activity.findViewById(R.id.order_summary_items);
    mOrderSummarySubtotal = (TextView) activity.findViewById(R.id.order_summary_subtotal);
    mOrderSummarySavings = (TextView) activity.findViewById(R.id.order_summary_savings);
    mOrderSummaryTax = (TextView) activity.findViewById(R.id.order_summary_tax);
    mOrderSummaryShipping = (TextView) activity.findViewById(R.id.order_summary_shipping);
    mOrderSummaryTotal = (TextView) activity.findViewById(R.id.order_summary_total);
    mOrderSummaryPromotion = (TextView) activity.findViewById(R.id.order_summary_promotion);
    mOrderSummarySavingsRow = (TableRow) activity.findViewById(R.id.order_summary_savings_row);

    if (order != null) {

        populatePromotions(order);

        // Display total price
        if (order.getTotalPrice() != null) {
            mOrderSummaryTotal.setText(order.getTotalPrice().getFormattedValue());
        }

        // Display subtotal price
        if (order.getSubTotal() != null) {
            mOrderSummarySubtotal.setText(order.getSubTotal().getFormattedValue());
        }

        // Display tax price
        if (order.getTotalTax() != null) {
            mOrderSummaryTax.setText(order.getTotalTax().getFormattedValue());
        }

        // Display delivery method cost
        if (order.getDeliveryCost() != null) {
            mOrderSummaryShipping.setText(order.getDeliveryCost().getFormattedValue());
        }

        if (order.getAppliedOrderPromotions() != null && !order.getAppliedOrderPromotions().isEmpty()) {
            if (StringUtils.isNotBlank(order.getOrderDiscounts().getFormattedValue())) {
                mOrderSummarySavingsRow.setVisibility(View.VISIBLE);
                mOrderSummarySavings.setText(order.getOrderDiscounts().getFormattedValue());
            }
        }

        if (order.getAppliedOrderPromotions() != null || order.getAppliedProductPromotions() != null) {
            if (order.getAppliedProductPromotions() != null && !order.getAppliedProductPromotions().isEmpty()) {
                mOrderSummaryPromotion.setVisibility(View.VISIBLE);
                // Nb order Promotion
                StringBuffer promotion = new StringBuffer();

                if (order.getAppliedOrderPromotions() != null && !order.getAppliedOrderPromotions().isEmpty()) {
                    for (PromotionResult orderPromotion : order.getAppliedOrderPromotions()) {
                        promotion.append(orderPromotion.getDescription()).append("\n");
                    }
                }

                mOrderSummaryPromotion.setText(promotion);
            } else {
                mOrderSummaryPromotion.setVisibility(View.GONE);
            }
        } else {
            mOrderSummaryPromotion.setVisibility(View.GONE);
            mOrderSummarySavingsRow.setVisibility(View.GONE);
        }

        // Nb items
        mOrderSummaryItemsLayout.setVisibility(View.VISIBLE);
        mOrderSummaryItems
                .setText(activity.getString(R.string.order_summary_items, order.getDeliveryItemsQuantity()));
    }
}

From source file:com.silentcircle.silenttext.activity.AccountCreationActivity.java

@Override
public void onError(final CharSequence message) {

    runOnUiThread(new Runnable() {

        @Override//from www  .  j  ava  2 s  .  c o m
        public void run() {
            TextView error = (TextView) findViewById(R.id.error);
            error.setText(
                    message == null || message.length() <= 0 ? getString(R.string.error_unknown) : message);
            error.setVisibility(View.VISIBLE);
            error.startAnimation(AnimationUtils.loadAnimation(error.getContext(), R.anim.slide_down));
            handler.removeCallbacks(hideError);
            handler.postDelayed(hideError, 5000);
        }

    });

}

From source file:net.evecom.androidecssp.activity.event.ContinueInfoActivity.java

/**
 * /*from w  w  w. j  a v  a 2s. co  m*/
 * 
 * 
 * @author Stark Zhou
 * @created 2015-12-30 3:03:01
 */
private void init() {

    typeValueKeyMap.put("1", "");
    typeValueKeyMap.put("2", "");
    TextView continueName = (TextView) findViewById(R.id.continue_name);
    continueName.setText(ifnull(continueInfo.get("coutinuename") + "", ""));
    TextView continueType = (TextView) findViewById(R.id.continue_type);
    if (continueInfo.get("coutinuetype") != null
            && continueInfo.get("coutinuetype").toString().equals("null") == false) {
        continueType.setText(ifnull(typeValueKeyMap.get(continueInfo.get("coutinuetype")).toString(), ""));
    }
    TextView reportTime = (TextView) findViewById(R.id.continue_reporttime);
    reportTime.setText(ifnull(continueInfo.get("reporterdate") + "", ""));
    TextView continueArea = (TextView) findViewById(R.id.continue_area);
    continueArea.setText(ifnull(continueInfo.get("areaname") + "", ""));
    TextView continueAddr = (TextView) findViewById(R.id.continue_addr);
    continueAddr.setText(ifnull(continueInfo.get("happenaddress") + "", ""));
    TextView continueTime = (TextView) findViewById(R.id.continue_time);
    continueTime.setText(ifnull(continueInfo.get("happendate") + "", ""));
    TextView continueDept = (TextView) findViewById(R.id.continue_dept);
    continueDept.setText(ifnull(continueInfo.get("deptname") + "", ""));
    TextView continueReporter = (TextView) findViewById(R.id.continue_reporter);
    continueReporter.setText(ifnull(continueInfo.get("reporterperson") + "", ""));
    TextView continueReporterTel = (TextView) findViewById(R.id.continue_reportertel);
    continueReporterTel.setText(ifnull(continueInfo.get("reportertel") + "", ""));
    TextView continueStep = (TextView) findViewById(R.id.continue_step);
    continueStep.setText(ifnull(continueInfo.get("takensteps") + "", ""));
    TextView continueContent = (TextView) findViewById(R.id.continue_content);
    continueContent.setText(ifnull(continueInfo.get("coutinuecontent") + "", ""));
    monitorView = (TextView) findViewById(R.id.continue_monitor);
    initGallery();
}

From source file:com.bt.download.android.gui.adapters.SearchResultListAdapter.java

protected void populateAppiaPart(View view, AppiaSearchResult sr) {
    TextView adIndicator = findView(view, R.id.view_bittorrent_search_result_list_item_ad_indicator);
    adIndicator.setVisibility(View.VISIBLE);

    TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra);
    extra.setText(sr.getCategoryName() + " : " + sr.getDescription());

    //TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds);
    //String license = sr.getLicense().equals(License.UNKNOWN) ? "" : " - " + sr.getLicense();

    TextView sourceLink = findView(view, R.id.view_bittorrent_search_result_list_item_text_source);
    sourceLink.setText(sr.getSource());//from  w w w .  j  a  va  2 s  .c o  m
    sourceLink.setTag(sr.getDetailsUrl());
    sourceLink.setPaintFlags(sourceLink.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    sourceLink.setOnClickListener(linkListener);
}

From source file:com.microsoft.onedrive.apiexplorer.DeltaFragment.java

/**
 * Refresh the UI//  ww  w  . j  a va 2  s .  c  o m
 */
private void refresh() {
    if (getView() != null) {
        getView().findViewById(android.R.id.progress).setVisibility(View.VISIBLE);
        final TextView jsonView = (TextView) getView().findViewById(R.id.json);
        jsonView.setVisibility(View.INVISIBLE);
        jsonView.setText("");
        mCurrentPagesCount.set(0);
    }

    final String deltaToken = getDeltaInfo().getString(mItemId, null);
    final Activity activity = getActivity();
    ((BaseApplication) activity.getApplication()).getOneDriveClient().getDrive().getItems(mItemId)
            .getDelta(deltaToken).buildRequest().select("id,name,deleted").get(pageHandler());
}

From source file:fm.krui.kruifm.ScheduleFragment.java

/**
 * Adds a show to the schedule./*from   w  ww.java  2s.c  o m*/
 * @param title Title of show to display
 * @param description Description of show to display
 * @param startTime Start time of show in minutes from midnight
 * @param endTime End time of show in minutes from midnight
 * @param category Format of this show, required to correctly color the event.
 *
 * Valid settings for category include:
 *                 1 - Regular Rotation
 *                 2 - Music Speciality
 *                 3 - Sports
 *                 4 - News/Talk
 *                 5 - Specials
 */
private void addShow(String title, String description, int startTime, int endTime, int category) {

    /* Build the LinearLayout to function as the container for this show. Since the size of the container is to represent
    the length of the show, its height must be proportional (1dp = 1 minute) to the length. Determine length by finding the difference
    between the start and end times. */

    // Fix for corner case of shows ending at midnight.
    if (endTime == 0) {
        endTime = 1440;
    }
    int difference = endTime - startTime;

    /* Define the margins of this show. All shows must not overlap the displayed times, which are 50dp in width.
    Add 5 more (to the right and left) to see the schedule lines for clarity. Push the show down to align with the appropriate time marker using the top margin value set to the
    difference (in minutes) between midnight and the start of the show. */

    Log.v(TAG, "Configuring " + title);
    //Log.v(TAG, "Start time: " + startTime + " End time: " + endTime);
    //Log.v(TAG, "Setting parameters for " + title);
    RelativeLayout.LayoutParams rrLayoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, dpToPixels(difference));
    rrLayoutParams.leftMargin = dpToPixels(55);
    //Log.v(TAG, "Left margin: " + rrLayoutParams.leftMargin);
    rrLayoutParams.topMargin = dpToPixels(startTime);
    //Log.v(TAG, "Top margin: " + rrLayoutParams.topMargin);
    rrLayoutParams.rightMargin = dpToPixels(5);
    //Log.v(TAG, "Right margin: " + rrLayoutParams.rightMargin);

    /* Build LinearLayout and apply parameters */
    LinearLayout eventLL = new LinearLayout(getActivity());
    eventLL.setOrientation(LinearLayout.VERTICAL);
    eventLL.setPadding(dpToPixels(5), dpToPixels(2), dpToPixels(5), dpToPixels(5));

    // Get background for this event
    eventLL.setBackgroundResource(getEventBackground(category));

    /* Add title of event to LinearLayout */
    TextView titleTV = new TextView(getActivity());

    // Title of a show should be bolded
    titleTV.setText(title);
    titleTV.setTypeface(null, Typeface.BOLD);
    titleTV.setPadding(dpToPixels(5), 0, dpToPixels(5), 0);
    eventLL.addView(titleTV);

    /* Determine length of event to see if we have room to attach a description (if one was passed) */
    int length = endTime - startTime;

    /* Attach a description with a size that depends on the event length (longer events can hold more description text). */
    if (description != null) {
        TextView descriptionTV = new TextView(getActivity());
        descriptionTV.setPadding(dpToPixels(5), dpToPixels(5), dpToPixels(5), dpToPixels(5));
        descriptionTV.setText(description);

        // ~hour long shows can display 1 line of description
        if (difference >= 30 && difference <= 60) {
            descriptionTV.setMaxLines(1);
        }

        // 1:30 long shows can display 2 lines of description
        else if (difference >= 60 && difference <= 90) {
            descriptionTV.setMaxLines(2);
        }

        // 2:00 long shows can display 4 lines of description
        else if (difference >= 120) {
            descriptionTV.setMaxLines(4);
        }

        descriptionTV.setEllipsize(TextUtils.TruncateAt.END);
        descriptionTV.setPadding(dpToPixels(5), dpToPixels(5), dpToPixels(5), dpToPixels(5));
        eventLL.addView(descriptionTV);
    }

    /* Add this view to the schedule UI */
    RelativeLayout rl = (RelativeLayout) rootView.findViewById(R.id.schedule_container_relativelayout);
    rl.addView(eventLL, rrLayoutParams);
}

From source file:samsungsami.io.example.samiremotecontrol.DeviceActivity.java

public void addFallback() {
    final ObjectMapper mapper = new ObjectMapper();
    TextView textView = new TextView(this);
    textView.setText("fallback");
    LinearLayout gridLayout = (LinearLayout) findViewById(R.id.gridLayout);

    gridLayout.addView(textView);/*ww w .  j a v a  2s . com*/

    final EditText editText;
    editText = new EditText(this);
    Button button = new Button(this);
    button.setText("send");
    button.setTextAppearance(this, android.R.style.TextAppearance_Small);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            MessagesApi msgApi = new MessagesApi();
            msgApi.setBasePath(SamiHelper.SAMIHUB_BASE_PATH);
            msgApi.getInvoker().addDefaultHeader("Authorization", "bearer " + SamiHelper.getAccessToken());

            sendCommandMessage = new Message();
            sendCommandMessage.setSdid(did);
            sendCommandMessage.setDdid(did);
            sendCommandMessage.setToken("fakeToken");

            try {
                Map<String, Object> messageData = mapper.readValue(editText.getText().toString(), Map.class);
                sendCommandMessage.setData(messageData);
                new CallPostMessageApiInBackground().execute(msgApi);

            } catch (IOException e) {
            }

        }
    });
    gridLayout.addView(editText);
    gridLayout.addView(button);
}

From source file:com.cssweb.android.quote.QuoteDetail.java

/**
 * ???/*from  w w w.j  a  va 2 s  . c o  m*/
 */
private void initLoading() {
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setPadding(0, 0, 15, 0);
    LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    LayoutParams layoutParams2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.FILL_PARENT);
    layout.addView(progressBar, layoutParams);
    TextView textView = new TextView(this);
    textView.setText(getResources().getText(R.string.cjmx_loading));
    textView.setGravity(Gravity.CENTER_VERTICAL);
    layout.addView(textView, layoutParams2);
    layout.setGravity(Gravity.CENTER);
    loadingLayout = new LinearLayout(this);
    loadingLayout.addView(layout, layoutParams);
    loadingLayout.setGravity(Gravity.CENTER);
    table_1.addView(loadingLayout, 0);
}