List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:com.manning.androidhacks.hack041.ArticleActivity.java
public void handleDataLoaded(ArticleModel model) { dialog.dismiss();/*from w ww.ja v a2 s . co m*/ task.detach(); task = null; // Fill out the views for this Activity. TextView title = (TextView) findViewById(R.id.article_title); title.setText(model.article.getTitle()); TextView subTitle = (TextView) findViewById(R.id.article_sub_title); subTitle.setText(model.getSubTitleText()); TextView articleText = (TextView) findViewById(R.id.article_text); articleText.setText(model.article.getText()); findViewById(R.id.divider).setVisibility(View.VISIBLE); updateCommentCount(model.commentCount); // Setup click events. findViewById(R.id.addComment).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { addCommentPrompt(); } }); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE TEXT ROW//ww w .ja va2s . c o m * @param att * @param linear * @return */ public LinearLayout getSingleTextRow(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, LayoutParams.WRAP_CONTENT, 0.5f); TextView t2 = new TextView(context); t2.setText(att.get("value").equals("") ? " - " : att.get("value")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t2, value_params); linear.addView(container_layout); return linear; }
From source file:com.starwood.anglerslong.LicenseActivity.java
private void createTextView() { if (isCreateTextViewSet) return;/*from w w w . jav a 2 s . com*/ // Get the linear layout and set the parameters LinearLayout ll = (LinearLayout) findViewById(R.id.profile_ll); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; TextView createLicense = new TextView(this); createLicense.setId(0); createLicense.setText(Html.fromHtml(getResources().getString(R.string.create_license_string))); createLicense.setPadding(70, 100, 70, 100); createLicense.setTextSize(18); ll.addView(createLicense, params); isCreateTextViewSet = true; }
From source file:com.mobileobservinglog.AvailableCatalogsTab.java
/** * Internal method to handle preparation of the list view upon creation or to be called by setLayout when session mode changes or onResume. *///from w w w .j a v a2 s.c om protected void prepareListView() { super.prepareListView(); if (availableCatalogList.size() == 0) { submitButton.setVisibility(View.GONE); TextView nothingLeft = (TextView) findViewById(R.id.nothing_left); nothingLeft.setText(R.string.no_available_catalogs); nothingLeft.setVisibility(0); } else { setListAdapter(new CatalogAdapter(this, settingsRef.getAddCatalogsListLayout(), availableCatalogList)); } }
From source file:com.bt.download.android.gui.adapters.SearchResultListAdapter.java
protected void populateTorrentPart(View view, TorrentSearchResult sr) { TextView seeds = findView(view, R.id.view_bittorrent_search_result_list_item_text_seeds); if (sr.getSeeds() > 0) { seeds.setText(getContext().getResources().getQuantityString(R.plurals.count_seeds_source, sr.getSeeds(), sr.getSeeds()));/* w ww . java2 s . c om*/ } else { seeds.setText(""); } }
From source file:net.idlesoft.android.apps.github.activities.Branch.java
@Override public void onCreate(final Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.branch);/* w ww. j av a2s. c o m*/ mPrefs = getSharedPreferences(Hubroid.PREFS_NAME, 0); mUsername = mPrefs.getString("username", ""); mPassword = mPrefs.getString("password", ""); mGapi.authenticate(mUsername, mPassword); ((ImageButton) findViewById(R.id.btn_search)).setOnClickListener(new OnClickListener() { public void onClick(final View v) { startActivity(new Intent(Branch.this, Search.class)); } }); final Bundle extras = getIntent().getExtras(); if (extras != null) { mRepositoryName = extras.getString("repo_name"); mRepositoryOwner = extras.getString("repo_owner"); mBranchName = extras.getString("branch_name"); mBranchSha = extras.getString("branch_sha"); final TextView branchName = (TextView) findViewById(R.id.tv_branch_name); final TextView branchSha = (TextView) findViewById(R.id.tv_branch_sha); final ListView infoList = (ListView) findViewById(R.id.lv_branch_infoList); branchName.setText(mBranchName); branchSha.setText(mBranchSha); infoList.setAdapter(new ArrayAdapter<String>(Branch.this, R.layout.branch_info_item, R.id.tv_branchInfoItem_text1, new String[] { "Commit Log", "View Branch's Tree" })); infoList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View v, final int position, final long id) { if (position == 0) { mIntent = new Intent(Branch.this, CommitsList.class); mIntent.putExtra("repo_owner", mRepositoryOwner); mIntent.putExtra("repo_name", mRepositoryName); mIntent.putExtra("branch_name", mBranchName); startActivity(mIntent); } else if (position == 1) { mIntent = new Intent(Branch.this, BranchTree.class); mIntent.putExtra("repo_owner", mRepositoryOwner); mIntent.putExtra("repo_name", mRepositoryName); mIntent.putExtra("branch_name", mBranchName); mIntent.putExtra("branch_sha", mBranchSha); startActivity(mIntent); } } }); } }
From source file:pl.bcichecki.rms.client.android.dialogs.DeviceDetailsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { if (device == null) { throw new IllegalStateException("Device has not been set!"); }/*from ww w. jav a 2 s . c o m*/ context = getActivity(); eventsRestClient = new EventsRestClient(getActivity(), UserProfileHolder.getUsername(), UserProfileHolder.getPassword(), SharedPreferencesWrapper.getServerRealm(), SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(), SharedPreferencesWrapper.getWebserviceContextPath()); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()); dialogBuilder.setTitle(getString(R.string.dialog_device_details_title, device.getName())); dialogBuilder.setView(getActivity().getLayoutInflater().inflate(R.layout.dialog_device_details, null)); dialogBuilder.setNeutralButton(R.string.dialog_device_details_btn_show_reservations, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Date now = new Date(); final Date from = DateUtils.round(DateUtils.addDays(now, DAYS_BACK - 1), Calendar.DAY_OF_MONTH); final Date till = DateUtils.round(DateUtils.addDays(now, DAYS_AHEAD + 1), Calendar.DAY_OF_MONTH); final FragmentManager fragmentManager = getFragmentManager(); Log.d(getTag(), "Retrieving device's events for " + device); eventsRestClient.getDevicesEvents(device, from, till, new GsonHttpResponseHandler<List<Event>>(new TypeToken<List<Event>>() { }.getType(), true) { @Override public void onFailure(Throwable error, String content) { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " failed. [error=" + error + ", content=" + content + "]"); if (error instanceof HttpResponseException) { if (((HttpResponseException) error) .getStatusCode() == HttpStatus.SC_UNAUTHORIZED) { AppUtils.showCenteredToast(context, R.string.general_unathorized_error_message_title, Toast.LENGTH_LONG); } else { AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } else { AppUtils.showCenteredToast(context, R.string.general_unknown_error_message_title, Toast.LENGTH_LONG); } } @Override public void onFinish() { Log.d(getTag(), "Retrieving device's events finished."); } @Override public void onStart() { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " started."); } @Override public void onSuccess(int statusCode, List<Event> events) { Log.d(getTag(), "Retrieving device's events from " + from.toString() + " till " + till.toString() + " successful. Retrieved " + events.size() + " objects."); DeviceReservationsDialog deviceReservationsDialog = new DeviceReservationsDialog(); deviceReservationsDialog.setDevice(device); deviceReservationsDialog.setEvents(events); deviceReservationsDialog.show(fragmentManager, getTag()); } }); } }); 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 nameTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_device_details_name_text); nameTextView.setText(device.getName()); TextView descriptionTextView = (TextView) ((AlertDialog) dialog) .findViewById(R.id.dialog_device_details_description_text); descriptionTextView.setText(device.getName()); } }); return dialog; }
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 = "https://www.packtpub.com/"; StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() { @Override//from w w w . j av a 2 s . co m public void onResponse(String response) { textView.setText(response.substring(0, 500)); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { textView.setText("onErrorResponse(): " + error.getMessage()); } }); queue.add(stringRequest); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * DOUBLE TITLE ROW//w ww . j ava2s .c o m * @param att * @param linear * @return */ public LinearLayout getDoubleTitleRow(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); container_layout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.3f); TextView tx = new TextView(context); tx.setText(""); 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.35f); TextView t1 = new TextView(context); t1.setText(att.get("value1")); 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); LinearLayout.LayoutParams ltext2 = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.35f); TextView t2 = new TextView(context); t2.setText(att.get("value2")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(255, 255, 255)); container_layout.addView(t2, ltext2); linear.addView(container_layout); return linear; }