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:gov.sfmta.sfpark.DetailViewActivity.java

public View headerText(String val) {
    View header = View.inflate(this, R.layout.header_row, null);
    TextView title = (TextView) header.findViewById(R.id.header_title);
    title.setText(val);
    return header;
}

From source file:se.anyro.tagtider.StationActivity.java

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

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.transfers);/* w ww .ja  v  a2  s . c o  m*/

    Bundle extras = getIntent().getExtras();

    mStationName = extras.getString("stationName");
    mStationId = extras.getInt("stationId");
    mType = extras.getString("type");

    if (!mType.equals(sLastType) || mStationId != sLastStationId) {
        sLastUpdate = 0; // Make sure we reload the data
        sLastStationId = mStationId;
        sLastType = mType;
    }

    TextView title = (TextView) findViewById(R.id.title);
    TextView place = (TextView) findViewById(R.id.place);
    if (Station.ARRIVIALS.equals(mType)) {
        title.setText(mStationName + " - Ankomster");
        mFrom = FROM_ARRIVAL;
        place.setText("Frn");
    } else {
        title.setText(mStationName + " - Avgngar");
        mFrom = FROM_DEPARTURE;
        place.setText("Till");
    }
    mEmptyView = (TextView) findViewById(android.R.id.empty);
    mProgress = findViewById(R.id.progress);
}

From source file:pl.bcichecki.rms.client.android.dialogs.InboxMessageDetailsDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (message == null) {
        throw new IllegalStateException("Message has not been set!");
    }/*  w ww  . jav  a 2s.co m*/
    if (messagesRestClient == null) {
        throw new IllegalStateException("MessagesRestClient has not been set!");
    }
    if (inboxMessagesListAdapter == null) {
        throw new IllegalStateException("InboxMessagesListAdapter has not been set!");
    }

    context = getActivity();

    markRead();

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
    dialogBuilder.setTitle(R.string.dialog_inbox_message_details_title);
    dialogBuilder
            .setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_inbox_message_details, null));
    dialogBuilder.setNeutralButton(R.string.dialog_inbox_message_details_reply,
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    MessageRecipent messageRecipent = new MessageRecipent();
                    messageRecipent.setRecipent(message.getSender());
                    HashSet<MessageRecipent> messageRecipents = new HashSet<MessageRecipent>();
                    messageRecipents.add(messageRecipent);
                    Message replyMessage = new Message();
                    replyMessage.setSubject(
                            getString(R.string.dialog_inbox_message_details_re) + ": " + message.getSubject());
                    replyMessage.setRecipents(messageRecipents);

                    Log.d(getTag(), "Starting reply message activity...");
                    Intent newMessageIntent = new Intent(context, NewMessageActivity.class);
                    newMessageIntent.putExtra(MESSAGE_EXTRA, replyMessage);
                    startActivityForResult(newMessageIntent, REQUEST_CODE_SEND_MESSAGE);
                }
            });
    dialogBuilder.setPositiveButton(R.string.general_close, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Nothing to do...
        }
    });

    AlertDialog dialog = dialogBuilder.create();
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            TextView subjectTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_subject_text);
            subjectTextView.setText(message.getSubject());

            StringBuilder sender = new StringBuilder();
            if (message.getSender().getAddress() != null
                    && message.getSender().getAddress().getFirstName() != null
                    && message.getSender().getAddress().getLastName() != null) {
                sender.append(message.getSender().getAddress().getFirstName()).append(" ")
                        .append(message.getSender().getAddress().getLastName());
            } else {
                sender.append(message.getSender().getUsername());
            }

            TextView senderTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_sender_text);
            senderTextView.setText(sender.toString());

            TextView receivedDataTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_received_date_text);
            receivedDataTextView
                    .setText(AppUtils.getFormattedDateAsString(message.getDate(), Locale.getDefault()));

            TextView contentTextView = (TextView) ((AlertDialog) dialog)
                    .findViewById(R.id.dialog_inbox_message_details_content_text);
            contentTextView.setText(message.getContent());
        }
    });

    return dialog;
}

From source file:net.idlesoft.android.apps.github.activities.Repository.java

public void loadRepoInfo() {
    try {/*ww  w .j  a v  a 2 s  . c o  m*/
        // TextView title =
        // (TextView)findViewById(R.id.tv_top_bar_title);
        // title.setText(m_jsonData.getString("name"));
        final TextView repo_name = (TextView) findViewById(R.id.tv_repository_info_name);
        repo_name.setText(mJson.getString("name"));
        repo_name.requestFocus();
        final TextView repo_desc = (TextView) findViewById(R.id.tv_repository_info_description);
        repo_desc.setText(mJson.getString("description"));
        final TextView repo_owner = (TextView) findViewById(R.id.tv_repository_info_owner);
        repo_owner.setText(mJson.getString("owner"));
        final TextView repo_watcher_count = (TextView) findViewById(R.id.tv_repository_info_watchers);
        if (mJson.getInt("watchers") == 1) {
            repo_watcher_count.setText(mJson.getInt("watchers") + " watcher");
        } else {
            repo_watcher_count.setText(mJson.getInt("watchers") + " watchers");
        }
        final TextView repo_fork_count = (TextView) findViewById(R.id.tv_repository_info_forks);
        if (mJson.getInt("forks") == 1) {
            repo_fork_count.setText(mJson.getInt("forks") + " fork");
        } else {
            repo_fork_count.setText(mJson.getInt("forks") + " forks");
        }
        final TextView repo_website = (TextView) findViewById(R.id.tv_repository_info_website);
        if (mJson.getString("homepage") != "") {
            repo_website.setText(mJson.getString("homepage"));
        } else {
            repo_website.setText("N/A");
        }

        /* Make the repository owner text link to his/her profile */
        repo_owner.setMovementMethod(LinkMovementMethod.getInstance());
        final Spannable spans = (Spannable) repo_owner.getText();
        final ClickableSpan clickSpan = new ClickableSpan() {
            @Override
            public void onClick(final View widget) {
                final Intent i = new Intent(Repository.this, Profile.class);
                try {
                    i.putExtra("username", mJson.getString("owner"));
                } catch (final JSONException e) {
                    e.printStackTrace();
                }
                startActivity(i);
            }
        };
        spans.setSpan(clickSpan, 0, spans.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } catch (final JSONException e) {
        e.printStackTrace();
    }

    ((Button) findViewById(R.id.btn_repository_info_branches)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, BranchesList.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("repo_owner", mRepositoryOwner);
            startActivity(intent);
        }
    });
    ((Button) findViewById(R.id.btn_repository_info_issues)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, Issues.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("repo_owner", mRepositoryOwner);
            startActivity(intent);
        }
    });
    ((Button) findViewById(R.id.btn_repository_info_network)).setOnClickListener(new OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent(Repository.this, NetworkList.class);
            intent.putExtra("repo_name", mRepositoryName);
            intent.putExtra("username", mRepositoryOwner);
            startActivity(intent);
        }
    });
}

From source file:mad.codeforcommunity.CalendarView.java

public void refreshCalendar() {
    TextView title = (TextView) findViewById(R.id.title);

    adapter.refreshDays();// w  w  w .j av a2  s.co m
    adapter.notifyDataSetChanged();
    handler.post(calendarUpdater); // generate some random calendar items            

    title.setText(android.text.format.DateFormat.format("MMMM yyyy", month));
}

From source file:com.df.app.carsWaiting.CarsWaitingListActivity.java

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

    swipeListView = (SwipeListView) findViewById(R.id.carsWaitingList);

    data = new ArrayList<CarsWaitingItem>();

    adapter = new CarsWaitingListAdapter(this, data, new CarsWaitingListAdapter.OnAction() {
        @Override// w  w  w. ja  v  a 2  s  . c  o  m
        public void onEditPressed(int position) {
            swipeListView.openAnimate(position);
        }

        @Override
        public void onModifyProcedure(int positon) {
            CarsWaitingItem item = data.get(positon);
            Intent intent = new Intent(CarsWaitingListActivity.this, InputProceduresActivity.class);
            intent.putExtra("carId", item.getCarId());
            startActivity(intent);
        }

        @Override
        public void onDeleteCar(final int position) {
            View view1 = getLayoutInflater().inflate(R.layout.popup_layout, null);
            TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea);
            TextView content = new TextView(view1.getContext());
            content.setText(R.string.confirmDeleteCar);
            content.setTextSize(20f);
            contentArea.addView(content);

            setTextView(view1, R.id.title, getResources().getString(R.string.alert));

            AlertDialog dialog = new AlertDialog.Builder(CarsWaitingListActivity.this).setView(view1)
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            CarsWaitingItem item = data.get(position);
                            deleteCar(item.getCarId());
                        }
                    }).setNegativeButton(R.string.cancel, null).create();

            dialog.show();
        }
    });

    swipeListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    swipeListView.setSwipeListViewListener(new BaseSwipeListViewListener() {
        @Override
        public void onClickFrontView(int position) {
            getCarDetail(data.get(position).getCarId(), CarCheckActivity.class);
        }

        @Override
        public void onDismiss(int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                data.remove(position);
            }
            adapter.notifyDataSetChanged();
        }

        @Override
        public void onStartOpen(int position, int action, boolean right) {
            swipeListView.closeOpenedItems();
        }
    });

    swipeListView.setSwipeMode(SwipeListView.SWIPE_MODE_LEFT);
    swipeListView.setSwipeActionLeft(SwipeListView.SWIPE_ACTION_REVEAL);
    swipeListView.setLongClickable(false);
    swipeListView.setSwipeOpenOnLongPress(false);
    swipeListView.setOffsetLeft(620);
    swipeListView.setAnimationTime(300);
    swipeListView.setAdapter(adapter);

    footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.footer, null, false);

    swipeListView.addFooterView(footerView);

    Button homeButton = (Button) findViewById(R.id.buttonHome);
    homeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finish();
        }
    });

    Button loadMoreButton = (Button) findViewById(R.id.loadMore);
    loadMoreButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            refresh(false);
        }
    });

    Button refreshButton = (Button) findViewById(R.id.buttonRefresh);
    refreshButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            refresh(true);
        }
    });

    refresh(true);
}

From source file:com.pursuer.reader.easyrss.WebpageItemViewCtrl.java

@SuppressLint("SimpleDateFormat")
private void showMobilizedPage() {
    showMobilized = true;/* www . j a va2s  .com*/
    view.findViewById(R.id.Mobilized).setVisibility(View.VISIBLE);
    view.findViewById(R.id.OriginalContent).setVisibility(View.GONE);
    view.findViewById(R.id.BtnMobilzedPage).setEnabled(false);
    view.findViewById(R.id.BtnOriginalPage).setEnabled(true);
    view.findViewById(R.id.OriginalProgress).setVisibility(View.GONE);
    view.findViewById(R.id.MobilizedProgress).setVisibility(View.VISIBLE);
    view.findViewById(R.id.MobilizedContent).setVisibility(View.GONE);
    final TextView title = (TextView) view.findViewById(R.id.ItemTitle);
    title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 3);
    title.setText(item.getTitle());
    final TextView info = (TextView) view.findViewById(R.id.ItemInfo);
    info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, fontSize * 4 / 5);
    final StringBuilder infoText = new StringBuilder();
    final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    sdf.setTimeZone(TimeZone.getDefault());
    infoText.append(sdf.format(Utils.timestampToDate(item.getTimestamp())));
    if (item.getAuthor() != null && item.getAuthor().length() > 0) {
        infoText.append(" | By ");
        infoText.append(item.getAuthor());
    }
    if (item.getSourceTitle() != null && item.getSourceTitle().length() > 0) {
        infoText.append(" (");
        infoText.append(item.getSourceTitle());
        infoText.append(")");
    }
    info.setText(infoText);
    if (thread == null) {
        thread = new Thread(new Runnable() {
            @SuppressWarnings("deprecation")
            @Override
            public void run() {
                try {
                    final StringBuilder urlBuilder = new StringBuilder();
                    urlBuilder.append("http://easyrss.pursuer.me/parser?url=");
                    urlBuilder.append(URLEncoder.encode(item.getHref()));
                    urlBuilder.append("&email=");
                    urlBuilder.append(URLEncoder.encode(dataMgr.getSettingByName(Setting.SETTING_USERNAME)));
                    urlBuilder.append("&version=");
                    urlBuilder.append(context.getString(R.string.Version));
                    final URLConnection connection = new URL(urlBuilder.toString()).openConnection();
                    connection.setConnectTimeout(30 * 1000);
                    connection.setReadTimeout(20 * 1000);
                    final InputStreamReader input = new InputStreamReader(connection.getInputStream());
                    final StringBuilder builder = new StringBuilder();
                    final char buff[] = new char[8192];
                    int len;
                    while ((len = input.read(buff)) != -1) {
                        builder.append(new String(buff, 0, len));
                    }
                    builder.append(theme == SettingTheme.THEME_NORMAL ? DataUtils.DEFAULT_NORMAL_CSS
                            : DataUtils.DEFAULT_DARK_CSS);
                    pageContent = builder.toString();
                    handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this));
                } catch (final MalformedURLException exception) {
                    exception.printStackTrace();
                    pageContent = genFailedToLoadContentPage(context, theme);
                    handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this));
                } catch (final IOException exception) {
                    exception.printStackTrace();
                    pageContent = genFailedToLoadContentPage(context, theme);
                    handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this));
                }
            }
        });
        thread.setPriority(Thread.MIN_PRIORITY);
        thread.start();
    } else if (!thread.isAlive()) {
        handler.sendMessage(handler.obtainMessage(MSG_LOADING_FINISHED, WebpageItemViewCtrl.this));
    }
}

From source file:MainActivity.java

public void sendRequest(View view) {
    final TextView textView = (TextView) findViewById(R.id.textView);
    RequestQueue queue = Volley.newRequestQueue(this);

    String url = "<json service>";
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null,
            new Response.Listener<JSONObject>() {
                @Override/*from ww  w.ja  va 2  s  . com*/
                public void onResponse(JSONObject response) {
                    textView.setText(response.toString());
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    textView.setText("onErrorResponse(): " + error.getMessage());
                }
            });
    queue.add(jsonObjectRequest);
}

From source file:com.example.android.wifidirect.DeviceDetailFragment.java

/**
 * Updates the UI with device data//from w w  w  . ja va 2  s.  c  o m
 * 
 * @param device the device to be displayed
 */
public void showDetails(WifiP2pDevice device) {
    this.device = device;
    this.getView().setVisibility(View.VISIBLE);
    TextView view = (TextView) mContentView.findViewById(R.id.device_address);
    view.setText(device.deviceAddress);
    view = (TextView) mContentView.findViewById(R.id.device_info);
    view.setText(device.toString());

}

From source file:com.dedipower.portal.android.ViewTicket.java

public void UpdateErrorMessage(String MessageText) {
    TextView ErrorMessage = (TextView) findViewById(R.id.ErrorMessageText);
    if (MessageText.length() == 0) {
        ErrorMessage.setHeight(0);/* ww  w  . j ava2s.  co m*/
    } else {

        ErrorMessage.setTextColor(-65536);
        ErrorMessage.setText(MessageText);
    }
}