List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:com.dedipower.portal.android.ManagedServerLanding.java
public void UpdateErrorMessage(String MessageText) { TextView ErrorMessage = (TextView) findViewById(R.id.ErrorMessageText); ErrorMessage.setTextColor(-65536);/*ww w .j ava2 s . com*/ ErrorMessage.setText(MessageText); }
From source file:com.app.sniffy.MainActivity.java
@Override public void onStart() { super.onStart(); SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); if (settings.getString("key", null) != null) { if (!isMyServiceRunning()) { // intent to start service Intent mServiceIntent = new Intent(this, SentBoxService.class); startService(mServiceIntent); }//from www .ja va 2 s. c o m } if (storedKey != null) { timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { runOnUiThread(new Runnable() { public void run() { String currentTime = df.format(new Date()); String[] time = currentTime.split(","); TextView digi_time = (TextView) findViewById(R.id.digi_time); digi_time.setText(time[0]); TextView digi_time_meredian = (TextView) findViewById(R.id.digi_time_meredian); digi_time_meredian.setText(time[1]); TextView digi_time_day = (TextView) findViewById(R.id.digi_time_day); digi_time_day.setText(time[2] + ","); TextView digi_time_date = (TextView) findViewById(R.id.digi_time_date); digi_time_date.setText(time[3]); } }); } }, 0, 1000); } }
From source file:com.bt.download.android.gui.adapters.SearchResultListAdapter.java
protected 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.idlesoft.android.apps.github.activities.Dashboard.java
@Override protected void onRestoreInstanceState(final Bundle savedInstanceState) { final TextView postTitle = (TextView) findViewById(R.id.tv_dashboard_latestPost_title); final TextView postLink = (TextView) findViewById(R.id.tv_dashboard_latestPost_link); postTitle.setText(savedInstanceState.getString("postTitle")); postLink.setText(savedInstanceState.getString("postLink")); super.onRestoreInstanceState(savedInstanceState); }
From source file:MainActivity.java
public void sendRequest(View view) { final TextView textView = (TextView) findViewById(R.id.textView); String url = "https://www.java2s.com/"; StringRequest stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() { @Override//from w w w . j a va2 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()); } }); stringRequest.setTag(this); mRequestQueue.add(stringRequest); finish(); }
From source file:com.pansapiens.occyd.NewPost.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // start polling location ASAP, so it can be accurate by the time // the post button is pressed locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); LocationUpdater locupdater = new LocationUpdater(locationManager); locupdater.startUpdating();//from w ww .ja v a 2 s . c o m setContentView(R.layout.newpost); final Button post_button = (Button) findViewById(R.id.post_button); post_button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String result_code = null; // get text from textboxes and encode it to be URL safe String desc = ((TextView) findViewById(R.id.desc_txt)).getText().toString(); String tags = ((TextView) findViewById(R.id.tags_txt)).getText().toString(); try { desc = URLEncoder.encode(desc, "UTF-8"); tags = URLEncoder.encode(tags, "UTF-8"); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // current API URL scheme uses commas between tags tags = tags.replace("+", ","); /* // turn space delimited tag list into a + delimited list, for the URL String[] tag_array = tags_txt.split(" "); String tags = null; for (int i = 0; i < tag_array.length; i++) { tags += tag_array[i]; if (i < tag_array.length-1) { tags += "+"; } } */ // TODO: put an accuracy check in here ... don't post if // the accuracy is too low ... // (or give a "really post with inaccurate location ?" warning) Location here = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); double lat = here.getLatitude(); double lon = here.getLongitude(); //Toast.makeText(NewPost.this, "Posting ...", // Toast.LENGTH_LONG).show(); try { String BASEURL = getString(R.string.occyd_server); String urlstr = String.format("%s/v1/posts/add?ll=%f,%f&desc=%s&tags=%s&link=%s", BASEURL, lat, lon, desc, tags, BASEURL); final URL url = new URL(urlstr); TextView tx = (TextView) findViewById(R.id.new_post_title); tx.setText(url.toString()); // run http fetch in a thread, with // 'posting' dialog final Thread tr = new Thread() { @Override public void run() { handle_result.post(mDisplayPosting); UrlFetch fetcher = new UrlFetch(url, handle_result); fetcher.fetch(); handle_result.post(mDismissPosting); } }; tr.start(); } catch (MalformedURLException e) { Toast.makeText(NewPost.this, "FAIL: Malformed URL.", Toast.LENGTH_LONG).show(); } catch (IOException e) { Toast.makeText(NewPost.this, "FAIL: http fetch failed.", Toast.LENGTH_LONG).show(); } } }); }
From source file:jp.co.anaheim_eng.camelliasample.MainActivity.java
@Override public void onClick(View v) { byte[] bytes; try {//from w w w . j a v a2 s. c o m switch (v.getId()) { case R.id.btn_encode: { if (getPreferences() == false) { Intent intent = new Intent(this, MainPreferenceActivity.class); startActivity(intent); return; } // Create Camellia Library object CamelliaLib cl = new CamelliaLib(mKeyBitLen, mPassword); Log.i("CamelliaSmaple", mPassword); Log.i("CamelliaSmaple", String.valueOf(Hex.encodeHex(cl.getHashDigt()))); cl.setPlainText(mPlainText); cl.Encode(); // Encode result mCiphers = cl.getCiphers(); StringBuilder sb = new StringBuilder(); sb.append("result size:" + String.valueOf(mCiphers.size()) + "\n"); sb.append("Camellia Encode result\n"); for (int i = 0; i < 3; i++) { sb.append("No." + String.valueOf(i + 1) + "\n"); sb.append("Plain Text:" + mPlainText.get(i) + "\n"); bytes = mCiphers.get(i); sb.append("Cipher :" + String.valueOf(Hex.encodeHex(bytes)) + "\n"); } TextView tv = (TextView) findViewById(R.id.textView1); tv.setText(sb); break; } case R.id.btn_decode: { if ((mCiphers == null) || (mCiphers.size() == 0)) { Toast.makeText(this, R.string.err_nonecipher, Toast.LENGTH_LONG).show(); return; } // Create Camellia Library object CamelliaLib cl = new CamelliaLib(mKeyBitLen, mPassword); cl.setCiphers(mCiphers); cl.Decode(); // Decode result mPlainText = cl.getPlainText(); StringBuilder sb = new StringBuilder(); sb.append("Camellia Decode result\n"); for (int i = 0; i < 3; i++) { sb.append("No." + String.valueOf(i + 1) + "\n"); bytes = mCiphers.get(i); sb.append("Cipher :" + String.valueOf(Hex.encodeHex(bytes)) + "\n"); sb.append("Plain Text:" + mPlainText.get(i) + "\n"); } TextView tv = (TextView) findViewById(R.id.textView1); tv.setText(sb); break; } case R.id.btn_file_encode: { if (getPreferences() == false) { Intent intent = new Intent(this, MainPreferenceActivity.class); startActivity(intent); return; } // Create Camellia Library object CamelliaLib cl = new CamelliaLib(mKeyBitLen, mPassword); Log.i("CamelliaSmaple", mPassword); Log.i("CamelliaSmaple", String.valueOf(Hex.encodeHex(cl.getHashDigt()))); boolean result = cl.FileEncode(mOriginFile, mEncryptFile, mTempDir); // Encode result StringBuilder sb = new StringBuilder(); if (result) { sb.append("Camellia File Encode result: success\n"); } else { sb.append("Camellia File Encode result: failure\n"); } TextView tv = (TextView) findViewById(R.id.textView1); tv.setText(sb); break; } case R.id.btn_file_decode: { if (getPreferences() == false) { Intent intent = new Intent(this, MainPreferenceActivity.class); startActivity(intent); return; } // Create Camellia Library object CamelliaLib cl = new CamelliaLib(mKeyBitLen, mPassword); boolean result = cl.FileDecode(mEncryptFile, mOriginFile, mTempDir); // Decode result StringBuilder sb = new StringBuilder(); if (result) { sb.append("Camellia File Decode result: success\n"); } else { sb.append("Camellia File Decode result: failure\n"); } TextView tv = (TextView) findViewById(R.id.textView1); tv.setText(sb); break; } case R.id.btn_pref: { Intent intent = new Intent(this, MainPreferenceActivity.class); startActivity(intent); break; } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.spoiledmilk.ibikecph.favorites.FavoritesAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View view = inflater.inflate(getListRowLayout(), parent, false); TextView tv = (TextView) view.findViewById(R.id.textFavoriteName); String name = getItem(position).getName(); if (name.length() > 19) name = name.substring(0, 19) + "..."; tv.setText(name); tv.setTypeface(IbikeApplication.getNormalFont()); tv.setTextColor(getTextColor());//from w w w.java2 s. c om ImageButton btnEdit = (ImageButton) view.findViewById(R.id.btnEdit); final FavoritesData fd = getItem(position); tv.setPadding(getPadding(fd), 0, 0, 0); btnEdit.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { fragment.onEditFavorite(fd); } }); final ImageView imgIcon = ((ImageView) view.findViewById(R.id.icon)); if (!isEditMode) { imgIcon.setImageResource(getIconResourceId(getItem(position))); btnEdit.setVisibility(View.GONE); } else { imgIcon.setImageResource(R.drawable.fav_reorder); btnEdit.setVisibility(View.VISIBLE); } return view; }
From source file:com.emobc.android.activities.generators.FormActivityGenerator.java
@Override protected void loadAppLevelData(final Activity activity, final AppLevelData data) { this.item = (FormLevelDataItem) data.findByNextLevel(nextLevel); //rotateScreen(activity); initializeHeader(activity, item);/* www .jav a2 s. c o m*/ controlsMap = new HashMap<String, View>(); //Create Banner CreateMenus c = (CreateMenus) activity; c.createBanner(); LinearLayout formLayout = (LinearLayout) activity.findViewById(R.id.formLayout); for (FormDataItem dataItem : item.getList()) { TextView label = new TextView(activity); label.setText(dataItem.getFieldLabel()); formLayout.addView(label); insertField(activity, dataItem, formLayout); } Button submit = new Button(activity); submit.setText(R.string.form_submit_buttom); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { processSubmit(activity); } }); formLayout.addView(submit); ((FormActivity) activity).setControlsMap(controlsMap); }
From source file:com.eyekabob.EventInfo.java
protected void loadEvent(JSONObject response) { try {// w w w.j a va2 s . c o m JSONObject jsonEvent = response.getJSONObject("event"); artists = new ArrayList<String>(); title = jsonEvent.getString("title"); JSONObject jsonAllArtists = jsonEvent.getJSONObject("artists"); headliner = jsonAllArtists.getString("headliner"); Object artistObj = jsonAllArtists.get("artist"); JSONArray jsonOpeners = new JSONArray(); if (artistObj instanceof JSONArray) { jsonOpeners = (JSONArray) artistObj; } for (int i = 0; i < jsonOpeners.length(); i++) { String artistName = jsonOpeners.getString(i); if (!headliner.equals(artistName)) { artists.add(artistName); } } JSONObject jsonVenue = jsonEvent.getJSONObject("venue"); venue = jsonVenue.optString("name"); venueCity = jsonVenue.optString("city"); venueStreet = jsonVenue.optString("street"); venueUrl = jsonVenue.optString("url"); startDate = EyekabobHelper.LastFM.toReadableDate(jsonEvent.getString("startDate")); JSONObject image = EyekabobHelper.LastFM.getLargestJSONImage(jsonEvent.getJSONArray("image")); imageUrl = image.getString("#text"); } catch (JSONException e) { Log.e(getClass().getName(), "", e); } try { new EventImageTask().execute(new URL(imageUrl)); } catch (MalformedURLException e) { Log.e(getClass().getName(), "Bad image URL [" + imageUrl + "]", e); } TextView titleView = (TextView) findViewById(R.id.infoMainHeader); titleView.setText(title); TextView headlinerView = (TextView) findViewById(R.id.infoSubHeaderOne); // TODO: I18N headlinerView.setText("Headlining: " + headliner); TextView dateTimeView = (TextView) findViewById(R.id.infoSubHeaderTwo); dateTimeView.setText(startDate); if (!startDate.equals("")) { Button tixButton = (Button) findViewById(R.id.infoTicketsButton); tixButton.setVisibility(View.VISIBLE); } LinearLayout artistsView = (LinearLayout) findViewById(R.id.infoFutureEventsContent); TextView alsoPerformingView = (TextView) findViewById(R.id.infoFutureEventsHeader); if (!artists.isEmpty()) { // TODO: I18N alsoPerformingView.setText("Also Performing:"); for (String artist : artists) { TextView row = new TextView(this); row.setTextColor(Color.WHITE); row.setText(artist); row.setPadding(20, 0, 0, 20); // Left and bottom padding artistsView.addView(row); } } String venueDesc = ""; TextView venueView = (TextView) findViewById(R.id.infoEventVenue); // TODO: Padding instead of whitespace venueDesc += " " + venue; if (!venueCity.equals("") && !venueStreet.equals("")) { // TODO: I18N venueDesc += "\n Address: " + venueStreet + "\n" + venueCity; } // TODO: Padding instead of whitespace venueDesc += "\n " + startDate; TextView venueTitleView = (TextView) findViewById(R.id.infoBioHeader); if (!venue.equals("") || !venueCity.equals("") || !venueStreet.equals("")) { // TODO: I18N venueTitleView.setText("Venue Details:"); View vView = findViewById(R.id.infoVenueDetails); vView.setVisibility(View.VISIBLE); } else { // TODO: I18N venueTitleView.setText("No Venue Details Available"); } venueView.setVisibility(View.VISIBLE); venueView.setText(venueDesc); TextView websiteView = (TextView) findViewById(R.id.infoVenueWebsite); if (!venueUrl.equals("")) { // TODO: I18N websiteView.setVisibility(View.VISIBLE); websiteView.setText(Html.fromHtml("<a href=\"" + venueUrl + "\">More Information</a>")); websiteView.setMovementMethod(LinkMovementMethod.getInstance()); } }