List of usage examples for android.widget TextView setText
@android.view.RemotableViewMethod public final void setText(@StringRes int resid)
From source file:com.eyekabob.ArtistInfo.java
/** * This method is called after the last.fm response is received. It will * parse the XML document response and put attributes on the Artist object. *//* ww w .j ava 2 s .c o m*/ protected void handleArtistResponse(JSONObject response) { try { JSONObject jsonArtist = response.optJSONObject("artist"); if (jsonArtist == null) { Toast.makeText(this, R.string.no_results, Toast.LENGTH_SHORT).show(); artistInfoReturned = true; dismissDialogIfReady(); return; } artist.setName(jsonArtist.getString("name")); artist.setMbid(jsonArtist.getString("mbid")); artist.setUrl(jsonArtist.getString("url")); JSONObject jsonImage = EyekabobHelper.LastFM.getLargestJSONImage(jsonArtist.getJSONArray("image")); // Get artist image, if one exists. if (null != jsonImage) { new ArtistImageTask().execute(new URL(jsonImage.getString("#text"))); } else { imageInfoReturned = true; dismissDialogIfReady(); } JSONObject bio = jsonArtist.getJSONObject("bio"); artist.setSummary(bio.getString("summary")); artist.setContent(bio.getString("content")); } catch (JSONException e) { Log.e(getClass().getName(), "", e); } catch (MalformedURLException e) { Log.e(getClass().getName(), "", e); } TextView artistNameView = (TextView) findViewById(R.id.infoMainHeader); artistNameView.setText(artist.getName()); if (!(artist.getSummary() == null) && !artist.getSummary().equals("")) { TextView bioHeaderView = (TextView) findViewById(R.id.infoBioHeader); // TODO: I18N bioHeaderView.setText("Bio"); TextView bioView = (TextView) findViewById(R.id.infoBioContent); String contentHtml = artist.getSummary(); bioView.setText(Html.fromHtml(contentHtml)); bioView.setVisibility(View.VISIBLE); } if (!(artist.getContent() == null) && !artist.getContent().equals("")) { ToggleButton tb = (ToggleButton) findViewById(R.id.infoBioToggleButton); tb.setVisibility(View.VISIBLE); } artistInfoReturned = true; dismissDialogIfReady(); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java
@Override public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { PackageManager pm = context.getPackageManager(); Drawable icon = null;//from w w w . j a v a 2 s .co m String appName; if (obj.getJson() != null && obj.getJson().has(ANDROID_PACKAGE_NAME)) { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); } else { appName = "Unknown"; } if (!(obj instanceof DbObj)) { if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Preparing application " + appName + "..."; // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); return; } DbObj dbParentObj = (DbObj) obj; boolean rendered = false; Intent launch = getLaunchIntent(context, dbParentObj); List<ResolveInfo> infos = pm.queryIntentActivities(launch, 0); if (infos.size() > 0) { ResolveInfo info = infos.get(0); if (info.activityInfo.labelRes != 0) { appName = info.activityInfo.loadLabel(pm).toString(); icon = info.loadIcon(pm); } else { appName = info.activityInfo.name; } } else { appName = obj.getJson().optString(ANDROID_PACKAGE_NAME); if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } } // TODO: Safer reference to containing view if (icon != null) { View parentView = (View) frame.getParent().getParent(); ImageView avatar = (ImageView) parentView.findViewById(R.id.icon); avatar.setImageDrawable(icon); TextView label = (TextView) parentView.findViewById(R.id.name_text); label.setText(appName); } // TODO: obj.getLatestChild().render(); String selection = getRenderableClause(); String[] selectionArgs = null; Cursor cursor = dbParentObj.getSubfeed().query(selection, selectionArgs); if (cursor.moveToFirst()) { DbObj dbObj = App.instance().getMusubi().objForCursor(cursor); DbObjects.getFeedRenderer(dbObj.getType()).render(context, frame, dbObj, allowInteractions); rendered = true; } if (!rendered) { String text; if (icon != null) { ImageView iv = new ImageView(context); iv.setImageDrawable(icon); iv.setAdjustViewBounds(true); iv.setMaxWidth(60); iv.setMaxHeight(60); iv.setLayoutParams(CommonLayouts.WRAPPED); frame.addView(iv); text = appName; } else { text = "New application: " + appName + "."; } // TODO: Show Market icon or app icon. TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }
From source file:es.uniovi.imovil.fcrtrainer.BinaryExerciseFragment.java
private void updatePointsTextView(int p) { TextView tvPoints = (TextView) rootView.findViewById(R.id.points); tvPoints.setText(getResources().getString(R.string.points) + " " + String.valueOf(p)); }
From source file:samsungsami.io.example.samiremotecontrol.DeviceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_device); // Retrieve the device identifiers dtid = getIntent().getStringExtra("dtid"); did = getIntent().getStringExtra("did"); manifestVersion = (BigDecimal) (getIntent().getExtras().get("manifestVersion")); // Retrieve the table layout propertiesTableLayout = (TableLayout) findViewById(R.id.tableLayout); // Display the device name and the device type name TextView textView; textView = (TextView) findViewById(R.id.deviceNameTextView); textView.setText(getIntent().getStringExtra("deviceName")); textView = (TextView) findViewById(R.id.deviceTypeNameTextView); textView.setText(getIntent().getStringExtra("deviceTypeName")); textView = (TextView) findViewById(R.id.action_header); textView = (TextView) findViewById(R.id.status_header); // Setup the back button Button backButton = (Button) findViewById(R.id.back_button); backButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(getApplicationContext(), DeviceListActivity.class)); finish();//ww w. j a va2 s. c om } }); // Download the Manifest DeviceTypesApi api = new DeviceTypesApi(); api.setBasePath(SamiHelper.SAMIHUB_BASE_PATH); api.getInvoker().addDefaultHeader("Authorization", "bearer " + SamiHelper.getAccessToken()); new CallDeviceTypesApiInBackground().execute(api); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LocationObj.java
@Override public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//w w w.ja v a 2 s .c o m TextView valueTV = new TextView(context); NumberFormat df = DecimalFormat.getNumberInstance(); df.setMaximumFractionDigits(5); df.setMinimumFractionDigits(5); String msg = "I'm at " + df.format(content.optDouble(COORD_LAT)) + ", " + df.format(content.optDouble(COORD_LONG)); valueTV.setText(msg); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); }
From source file:gov.wa.wsdot.android.wsdot.ui.YouTubeFragment.java
public void onLoadFinished(Loader<ArrayList<YouTubeItem>> loader, ArrayList<YouTubeItem> data) { if (!data.isEmpty()) { mAdapter.setData(data);/*from ww w . ja va 2 s. com*/ } else { TextView t = (TextView) mEmptyView; t.setText(R.string.no_connection); getListView().setEmptyView(mEmptyView); } swipeRefreshLayout.setRefreshing(false); }
From source file:de.hackerspacebremen.fragments.StatusFragment.java
private void outputStatus(final SpaceData data) { if (statusAnimation != null) { statusAnimation.stop();/*from w w w . j a v a 2 s.c om*/ } if (messageAnimation != null) { messageAnimation.stop(); } StatusViewHolder.get().imgStatus.setVisibility(ImageView.GONE); if (data == null) { StatusViewHolder.get().imgConnErr.setVisibility(ImageView.VISIBLE); final TextView statusView = StatusViewHolder.get().statusMessage; statusView.setText(this.getText(R.string.connection_error)); } else { this.spaceData = data; final TextView text = StatusViewHolder.get().statusMessage; String timeString = getString(R.string.unknown); if (data.getTime() != null) { timeString = SpeakingDateFormat.format(data.getTime()); } ((HackerspaceApplication) this.getActivity().getApplication()).spaceOpen = data.isSpaceOpen(); if (data.isSpaceOpen()) { text.setText(getString(R.string.space_open, timeString)); } else { text.setText(getString(R.string.space_closed, timeString)); } text.setTypeface(null, Typeface.BOLD); if (data.getMessage() != null && data.getMessage().length() > 0) { String message = data.getMessage(); final TextView messageView = StatusViewHolder.get().messageText; messageView.setText(message); final TextView messageLabel = StatusViewHolder.get().messageLabel; messageLabel.setVisibility(TextView.VISIBLE); StatusViewHolder.get().messageBlock.setVisibility(RelativeLayout.VISIBLE); } else { StatusViewHolder.get().messageBlock.setVisibility(RelativeLayout.INVISIBLE); } // TODO EventBus nutzen updateAppWidget(data); } }
From source file:fr.cph.stock.android.activity.AccountActivity.java
/** * Build UI//from ww w. java 2 s. c o m * * @param withAccounts */ private void buildUi(boolean withAccounts) { totalValueView.setText(portfolio.getTotalValue()); totalGainView.setText(portfolio.getTotalGain()); if (portfolio.isUp()) { totalGainView.setTextColor(Color.rgb(0, 160, 0)); } else { totalGainView.setTextColor(Color.rgb(160, 0, 0)); } totalPlusMinusValueView.setText(" (" + portfolio.getTotalPlusMinusValue() + ")"); if (portfolio.isUp()) { totalPlusMinusValueView.setTextColor(Color.rgb(0, 160, 0)); } else { totalPlusMinusValueView.setTextColor(Color.rgb(160, 0, 0)); } lastUpateView.setText(portfolio.getLastUpdate()); liquidityView.setText(portfolio.getLiquidity()); yieldYearView.setText(portfolio.getYieldYear()); shareValueView.setText(portfolio.getShareValues().get(0).getShareValue()); gainView.setText(portfolio.getGainPerformance()); perfView.setText(portfolio.getPerformancePerformance()); yieldView.setText(portfolio.getYieldPerformance()); taxesView.setText(portfolio.getTaxesPerformace()); if (withAccounts) { int j = 0; int size = portfolio.getAccounts().size(); for (int i = 0; i < size; i++) { Account account = portfolio.getAccounts().get(i); TextView currentAccountNameTextView = textViews.get(j++); currentAccountNameTextView.setText(account.getName()); TextView currentTextView = textViews.get(j++); currentTextView.setText(account.getLiquidity()); TextView currentCurrencyTextView = textViews.get(j++); currentCurrencyTextView.setText(account.getCurrency()); } } }
From source file:com.scigames.slidegame.ProfileActivity.java
public void onResultsSucceeded(String[] serverResponseStrings, JSONObject serverResponseJSON) throws JSONException { //download photo ImageView profilePhoto = (ImageView) findViewById(R.id.imageView1); profilePhoto.setTag(photoUrl);//from ww w . ja v a 2 s. com photoTask.cancel(true); photoTask = new DownloadProfilePhoto(ProfileActivity.this, photoUrl); //AsyncTask<ImageView, Void, Bitmap> pPhoto = photoTask.execute(profilePhoto); //update all text fields Resources res = getResources(); TextView greets = (TextView) findViewById(R.id.greeting); greets.setText(String.format(res.getString(R.string.greeting), serverResponseStrings[2], serverResponseStrings[3])); TextView fname = (TextView) findViewById(R.id.first_name); fname.setText(String.format(res.getString(R.string.profile_first_name), serverResponseStrings[2])); TextView lname = (TextView) findViewById(R.id.last_name); lname.setText(String.format(res.getString(R.string.profile_last_name), serverResponseStrings[3])); TextView school = (TextView) findViewById(R.id.school_name); school.setText(String.format(res.getString(R.string.profile_school_name), "from DB")); TextView teacher = (TextView) findViewById(R.id.teacher_name); teacher.setText(String.format(res.getString(R.string.profile_teacher_name), "from DB")); TextView classid = (TextView) findViewById(R.id.class_id); classid.setText(String.format(res.getString(R.string.profile_classid), serverResponseStrings[7])); TextView mmass = (TextView) findViewById(R.id.mass); mmass.setText(String.format(res.getString(R.string.profile_mass), serverResponseStrings[5])); TextView memail = (TextView) findViewById(R.id.email); memail.setText(String.format(res.getString(R.string.profile_email), serverResponseStrings[6])); TextView mpass = (TextView) findViewById(R.id.password); mpass.setText(String.format(res.getString(R.string.profile_password), serverResponseStrings[8])); TextView mRfid = (TextView) findViewById(R.id.rfid); mRfid.setText(String.format(res.getString(R.string.profile_rfid), serverResponseStrings[9])); Log.d(TAG, "...Profile Info"); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppStateObj.java
public void render(final Context context, final ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();// w w w. j a v a 2 s. co m // TODO: hack to show object history in app feeds JSONObject appState = getAppState(context, content); if (appState != null) { content = appState; } else { Log.e(TAG, "Missing inner content, probably because of format changes"); } boolean rendered = false; AppState ref = new AppState(content); String thumbnail = ref.getThumbnailImage(); if (thumbnail != null) { rendered = true; ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); App.instance().objectImages.lazyLoadImage(thumbnail.hashCode(), thumbnail, imageView); frame.addView(imageView); } thumbnail = ref.getThumbnailText(); if (thumbnail != null) { rendered = true; TextView valueTV = new TextView(context); valueTV.setText(thumbnail); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } thumbnail = ref.getThumbnailHtml(); if (thumbnail != null) { rendered = true; WebView webview = new WebView(context); webview.loadData(thumbnail, "text/html", "UTF-8"); webview.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); Object o = frame.getTag(R.id.object_entry); webview.setOnTouchListener(new WebViewClickListener(frame, (Integer) o)); frame.addView(webview); } if (!rendered) { String appName = content.optString(PACKAGE_NAME); if (appName.contains(".")) { appName = appName.substring(appName.lastIndexOf(".") + 1); } String text = "Welcome to " + appName + "!"; TextView valueTV = new TextView(context); valueTV.setText(text); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); } }