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.frostwire.android.gui.adapters.SearchResultListAdapter.java

private void populateYouTubePart(View view, YouTubeCrawledSearchResult sr) {
    TextView extra = findView(view, R.id.view_bittorrent_search_result_list_item_text_extra);
    extra.setText(FilenameUtils.getExtension(sr.getFilename()));
}

From source file:net.sf.asap.Player.java

private void setTag(int controlId, String value) {
    TextView control = (TextView) findViewById(controlId);
    if (value.length() == 0)
        control.setVisibility(View.GONE);
    else {/*www .  j  av  a2s  .c  o m*/
        control.setText(value);
        control.setVisibility(View.VISIBLE);
    }
}

From source file:com.entertailion.android.launcher.Dialogs.java

/**
 * Utility method to display an alert dialog. Use instead of AlertDialog to
 * get the right styling.//from   w  ww .  j a  v a 2s .c o m
 * 
 * @param context
 * @param message
 */
public static void displayAlert(final Launcher context, String message) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.alert);

    final TextView alertTextView = (TextView) dialog.findViewById(R.id.alertText);
    alertTextView.setText(message);
    Button alertButton = (Button) dialog.findViewById(R.id.alertButton);
    alertButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            context.showCover(false);
            dialog.dismiss();
        }

    });
    dialog.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            context.showCover(false);
        }

    });
    context.showCover(true);
    dialog.show();
}

From source file:com.scooter1556.sms.android.fragment.AudioDirectoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_audio_directory, container, false);

    mediaElementListAdapter = new MediaElementListAdapter(getActivity(), mediaElements);

    ImageView coverArt = (ImageView) rootView.findViewById(R.id.cover_art);

    Glide.with(getActivity().getBaseContext())
            .load(RESTService.getInstance().getConnection().getUrl() + "/image/" + id + "/cover/80")
            .error(R.drawable.ic_content_album).into(coverArt);

    TextView directoryTitle = (TextView) rootView.findViewById(R.id.directory_title);
    if (title != null) {
        directoryTitle.setText(title);
    }//from   w  w  w.ja  v  a  2 s .c o  m

    TextView directoryArtist = (TextView) rootView.findViewById(R.id.directory_artist);
    if (artist != null) {
        directoryArtist.setText(artist);
    }

    listView = (ListView) rootView.findViewById(R.id.songList);
    listView.setAdapter(mediaElementListAdapter);
    listView.setEmptyView(rootView.findViewById(R.id.emptyList));

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (actionMode == null) {
                if (mediaElementListener != null) {
                    mediaElementListener.MediaElementSelected(mediaElements.get(position));
                }
            } else {
                // Add or remove selection for current list item
                onListItemSelect(position);
            }
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int position, long id) {
            onListItemSelect(position);
            return true;
        }
    });

    return rootView;
}

From source file:com.p2c.thelife.SettingsFragment.java

@Override
public void notifyServerResponseAvailable(String indicator, int httpCode, JSONObject jsonObject,
        String errorString) {//  w  w w. jav a 2 s .  c  o m

    try {
        if (indicator.equals("queryUserProfile")) {

            // Update the UI with the result of the query.
            // But if the query failed, use the local information.

            // use the existing app user record
            UserModel user = TheLifeConfiguration.getOwnerDS().getOwner();

            // update app user record with latest from server
            if (Utilities.isSuccessfulHttpCode(httpCode) && jsonObject != null) {
                user.setFromPartialJSON(jsonObject);
                TheLifeConfiguration.getOwnerDS().setOwner(user);
            }

            // update the UI
            TextView textView = null;
            textView = (TextView) getActivity().findViewById(R.id.settings_first_name);
            textView.setText(user.firstName);
            textView = (TextView) getActivity().findViewById(R.id.settings_last_name);
            textView.setText(user.lastName);
            textView = (TextView) getActivity().findViewById(R.id.settings_email);
            textView.setText(user.email);
            textView = (TextView) getActivity().findViewById(R.id.settings_phone);
            textView.setText(user.mobile);

            // show the update photo prompt if there's no bitmap in the cache
            int ownerId = TheLifeConfiguration.getOwnerDS().getId();
            showUpdatePhotoPrompt(!UserModel.isInCache(ownerId));

            Bitmap bitmap = UserModel.getImage(ownerId);
            ImageView imageView = (ImageView) getActivity().findViewById(R.id.settings_image);
            imageView.setImageBitmap(bitmap);

            closeProgressBar();

        } else if (indicator.equals("updateUserProfile")) {

            if (Utilities.isSuccessfulHttpCode(httpCode)) {

                // update the app user
                TheLifeConfiguration.getOwnerDS().setOwner(m_updatedUser);

                // have updated the user profile, so now update the user profile image if necessary
                if (m_updatedBitmap != null) {
                    updateImageOnServer(m_updatedBitmap);
                } else {
                    closeProgressBar();
                    getActivity().getSupportFragmentManager().popBackStack();
                    Utilities.showInfoToast(getActivity(),
                            getResources().getString(R.string.user_profile_updated), Toast.LENGTH_SHORT);
                }
            } else {
                closeProgressBar();
            }

        } else if (indicator.equals("updateImage")) {

            if (Utilities.isSuccessfulHttpCode(httpCode)) {
                TheLifeConfiguration.getOwnerDS().notifyDSChangedListeners();
                m_updatedBitmap = null;
                Utilities.showInfoToast(getActivity(), getResources().getString(R.string.user_profile_updated),
                        Toast.LENGTH_SHORT);
            }
            closeProgressBar();
        }
    } catch (Exception e) {
        Log.e(TAG, "notifyServerResponseAvailable() " + indicator, e);
    }
}

From source file:fr.cph.chicago.core.activity.BusMapActivity.java

public void drawBuses(@NonNull final List<Bus> buses) {
    mapFragment.getMapAsync(googleMap -> {
        Stream.of(busMarkers).forEach(Marker::remove);
        busMarkers.clear();/*from   w  w  w .jav a  2  s. c o  m*/
        final BitmapDescriptor bitmapDescr = busListener.getCurrentBitmapDescriptor();
        Stream.of(buses).forEach(bus -> {
            final LatLng point = new LatLng(bus.getPosition().getLatitude(), bus.getPosition().getLongitude());
            final Marker marker = googleMap.addMarker(new MarkerOptions().position(point)
                    .title("To " + bus.getDestination()).snippet(bus.getId() + "").icon(bitmapDescr)
                    .anchor(0.5f, 0.5f).rotation(bus.getHeading()).flat(true));
            busMarkers.add(marker);

            final LayoutInflater layoutInflater = (LayoutInflater) BusMapActivity.this.getBaseContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final View view = layoutInflater.inflate(R.layout.marker_train, viewGroup, false);
            final TextView title = (TextView) view.findViewById(R.id.title);
            title.setText(marker.getTitle());

            views.put(marker, view);
        });

        busListener.setBusMarkers(busMarkers);
        googleMap.setOnCameraChangeListener(busListener);
    });
}

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

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

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

    swipeRefreshLayout.setRefreshing(false);
}

From source file:PagerSlidingTab.java

private void addTextTab(final int position, String title) {

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setFocusable(true);//from  w w  w .j  av  a2s .c o m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    tab.setLayoutParams(new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1));

    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);

}