List of usage examples for android.widget TextView setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:ca.ualberta.cmput301w14t08.geochan.adapters.ThreadViewAdapter.java
/** * Sets the required fields of the orignal post of the thread. * Title, creator, comment, timestamp, location. * /* w w w . j a v a 2 s . c om*/ * @param convertView * View container of a listView item. */ private void setOPFields(View convertView) { // Thread title TextView title = (TextView) convertView.findViewById(R.id.thread_view_op_threadTitle); // Special case of Viewing a Favourite Comment in ThreadView if (thread.getTitle().equals("")) { title.setVisibility(View.GONE); LinearLayout buttons = (LinearLayout) convertView.findViewById(R.id.thread_view_op_buttons); buttons.setVisibility(View.GONE); } else { title.setText(thread.getTitle()); } // Thread creator TextView threadBy = (TextView) convertView.findViewById(R.id.thread_view_op_commentBy); threadBy.setText( "Posted by " + thread.getBodyComment().getUser() + "#" + thread.getBodyComment().getHash() + " "); if (HashHelper.getHash(thread.getBodyComment().getUser()).equals(thread.getBodyComment().getHash())) { threadBy.setBackgroundResource(R.drawable.username_background_thread_rect); threadBy.setTextColor(Color.WHITE); } // Thread body comment TextView body = (TextView) convertView.findViewById(R.id.thread_view_op_commentBody); body.setText(thread.getBodyComment().getTextPost()); // Thread timestamp TextView threadTime = (TextView) convertView.findViewById(R.id.thread_view_op_commentDate); threadTime.setText(thread.getBodyComment().getCommentDateString()); // Location text TextView origPostLocationText = (TextView) convertView.findViewById(R.id.thread_view_op_locationText); GeoLocation loc = thread.getBodyComment().getLocation(); String locDescriptor = loc.getLocationDescription(); if (loc != null) { if (locDescriptor != null) { origPostLocationText.setText("near: " + locDescriptor); } else { // The rounding of long and lat for max 4 decimal digits. DecimalFormat format = new DecimalFormat(); format.setRoundingMode(RoundingMode.HALF_EVEN); format.setMinimumFractionDigits(0); format.setMaximumFractionDigits(4); origPostLocationText.setText("Latitude: " + format.format(loc.getLatitude()) + " Longitude: " + format.format(loc.getLongitude())); } } // Set the thumbnail if there is an image if (thread.getBodyComment().hasImage()) { ImageButton thumbnail = (ImageButton) convertView.findViewById(R.id.thread_view_comment_thumbnail); thumbnail.setVisibility(View.VISIBLE); thumbnail.setFocusable(false); thumbnail.setImageBitmap(thread.getBodyComment().getImageThumb()); } }
From source file:com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity.java
@Override protected Dialog onCreateDialog(int id) { if (id != DIALOG_RESULT_ID) { return null; }//from ww w. ja v a 2 s .c om view = getLayoutInflater().inflate(R.layout.upload_result, null); LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result); ImageView mapsResultIcon = (ImageView) view.findViewById(R.id.upload_result_maps_result_icon); TextView successFooter = (TextView) view.findViewById(R.id.upload_result_success_footer); TextView errorFooter = (TextView) view.findViewById(R.id.upload_result_error_footer); boolean hasError = false; if (!sendRequest.isSendNogago()) { mapsResult.setVisibility(View.GONE); } else { if (!sendRequest.isNogagoSuccess()) { mapsResultIcon.setImageResource(R.drawable.failure); mapsResultIcon.setContentDescription(getString(R.string.generic_error_title)); hasError = true; } } if (hasError) { successFooter.setVisibility(View.GONE); } else { errorFooter.setVisibility(View.GONE); } AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true) .setIcon(hasError ? android.R.drawable.ic_dialog_alert : android.R.drawable.ic_dialog_info) .setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { finish(); } }).setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }).setNeutralButton(R.string.dlg_btn_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); Intent settings = new Intent(UploadResultActivity.this, SettingsActivity.class); startActivity(settings); } }).setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title).setView(view); // Add a Share URL button if shareUrl exists if (shareUrl != null) { builder.setNegativeButton(R.string.share_track_share_url, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ChooseActivityDialogFragment.newInstance(sendRequest.getTrackId(), shareUrl).show( getSupportFragmentManager(), ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG); } }); } resultDialog = builder.create(); return resultDialog; }
From source file:com.concentricsky.android.khanacademy.app.TopicListActivity.java
@Override protected void onStart() { super.onStart(); stopped = false;/*from w w w . j av a 2 s . com*/ mainMenuDelegate = new MainMenuDelegate(this); gridView = (GridView) findViewById(R.id.activity_topic_list_grid); gridView.setOnItemClickListener(clickListener); ActionBar ab = getActionBar(); ab.setDisplayHomeAsUpEnabled(true); ab.setTitle("Topics"); requestDataService(new ObjectCallback<KADataService>() { @Override public void call(final KADataService dataService) { TopicListActivity.this.dataService = dataService; try { thumbnailManager = dataService.getThumbnailManager(); dao = dataService.getHelper().getTopicDao(); if (topicId != null) { topic = dao.queryForId(topicId); } else { topic = dataService.getRootTopic(); topicId = topic.getId(); } // DEBUG if (topic == null) return; // header headerView = findViewById(R.id.header_topic_list); ((TextView) headerView.findViewById(R.id.header_video_list_title)).setText(topic.getTitle()); String desc = topic.getDescription(); TextView descView = (TextView) headerView.findViewById(R.id.header_video_list_description); if (desc != null && desc.length() > 0) { descView.setText(Html.fromHtml(desc)); descView.setVisibility(View.VISIBLE); } else { descView.setVisibility(View.GONE); } // Find child count for this parent topic. boolean videoChildren = Topic.CHILD_KIND_VIDEO.equals(topic.getChild_kind()); String[] idArg = { topic.getId() }; String sql = videoChildren ? "select count() from topicvideo where topic_id=?" : "select count() from topic where parentTopic_id=?"; int count = (int) dao.queryRawValue(sql, idArg); String countFormat = getString( videoChildren ? R.string.format_video_count : R.string.format_topic_count); // Set header count string. ((TextView) headerView.findViewById(R.id.header_video_list_count)) .setText(String.format(countFormat, count)); final ImageView thumb = (ImageView) headerView.findViewById(R.id.header_video_list_thumbnail); if (thumb != null) { new AsyncTask<Void, Void, Bitmap>() { @Override public Bitmap doInBackground(Void... arg) { Bitmap bmp = thumbnailManager.getThumbnail( TopicListActivity.this.topic.getThumb_id(), Thumbnail.QUALITY_SD); return bmp; } @Override public void onPostExecute(Bitmap bmp) { thumb.setImageBitmap(bmp); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } // list if (topicCursor != null) { topicCursor.close(); } topicCursor = buildCursor(topicId); ListAdapter adapter = new TopicGridAdapter(topicCursor); gridView.setAdapter(adapter); // Request the topic and its children be updated from the api. List<Topic> children = dao.queryForEq("parentTopic_id", topic.getId()); List<String> toUpdate = new ArrayList<String>(); for (Topic child : children) { toUpdate.add(child.getId()); } toUpdate.add(topic.getId()); } catch (SQLException e) { e.printStackTrace(); } } }); IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_LIBRARY_UPDATE); filter.addAction(ACTION_BADGE_EARNED); filter.addAction(ACTION_TOAST); LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter); }
From source file:semanticweb.hws14.movapp.activities.MovieDetail.java
private void setData(final MovieDet movie) { Thread picThread = new Thread(new Runnable() { public void run() { try { ImageView img = (ImageView) findViewById(R.id.imageViewMovie); URL url = new URL(movie.getPoster()); HttpGet httpRequest;/*from ww w. jav a 2 s .c o m*/ httpRequest = new HttpGet(url.toURI()); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(httpRequest); HttpEntity entity = response.getEntity(); BufferedHttpEntity b_entity = new BufferedHttpEntity(entity); InputStream input = b_entity.getContent(); Bitmap bitmap = BitmapFactory.decodeStream(input); img.setImageBitmap(bitmap); } catch (Exception ex) { Log.d("MovieDetail Picture Error ", ex.toString()); } } }); picThread.start(); if (!"".equals(movie.getTitle())) { TextView movieTitle = (TextView) findViewById(R.id.tvMovieTitle); movieTitle.setText(movie.getTitle()); movieTitle.setVisibility(View.VISIBLE); } if (!"".equals(movie.getPlot())) { TextView moviePlot = (TextView) findViewById(R.id.tvPlot); moviePlot.setText(movie.getPlot()); moviePlot.setVisibility(View.VISIBLE); } TextView ageRestriction = (TextView) findViewById(R.id.tvAgeRestriction); TextView arHc = (TextView) findViewById(R.id.tvAgeRestrictionHC); String aR = String.valueOf(movie.getRated()); //Decode the ageRestriction if (!aR.equals("")) { ageRestriction.setVisibility(View.VISIBLE); arHc.setVisibility(View.VISIBLE); if (aR.equals("X")) { ageRestriction.setText("18+"); } else if (aR.equals("R")) { ageRestriction.setText("16+"); } else if (aR.equals("M")) { ageRestriction.setText("12+"); } else if (aR.equals("G")) { ageRestriction.setText("6+"); } else { ageRestriction.setVisibility(View.GONE); arHc.setVisibility(View.GONE); } } TextView ratingCount = (TextView) findViewById(R.id.tvMovieRatingCount); TextView ratingCountHc = (TextView) findViewById(R.id.tvMovieRatingCountHC); String ratingCountText = movie.getVoteCount(); ratingCount.setText(ratingCountText); manageEmptyTextfields(ratingCountHc, ratingCount, ratingCountText, false); if (!"".equals(movie.getImdbRating())) { TextView movieRating = (TextView) findViewById(R.id.tvMovieRating); if (movie.getImdbRating().equals("0 No Rating")) { movieRating.setText("No Rating"); } else if (movie.getImdbRating().equals("0 No Data")) { movieRating.setText(""); } else { movieRating.setText(movie.getImdbRating() + "/10"); } movieRating.setVisibility(View.VISIBLE); findViewById(R.id.tvMovieRatingHC).setVisibility(View.VISIBLE); } TextView metaScore = (TextView) findViewById(R.id.tvMetaScore); TextView metaScoreHc = (TextView) findViewById(R.id.tvMetaScoreHC); String metaSoreText = String.valueOf(movie.getMetaScore()); metaScore.setText(metaSoreText + "/100"); manageEmptyTextfields(metaScoreHc, metaScore, metaSoreText, false); TextView tvGenreHc = (TextView) findViewById(R.id.tvGenreHC); TextView genre = (TextView) findViewById(R.id.tvGenre); String genreText = String.valueOf(movie.createTvOutOfList(movie.getGenres())); genre.setText(genreText); manageEmptyTextfields(tvGenreHc, genre, genreText, true); TextView releaseYear = (TextView) findViewById(R.id.tvReleaseYear); TextView releaseYearHc = (TextView) findViewById(R.id.tvReleaseYearHC); String releaseYearText = String.valueOf(movie.getReleaseYear()); releaseYear.setText(releaseYearText); manageEmptyTextfields(releaseYearHc, releaseYear, releaseYearText, true); TextView runtime = (TextView) findViewById(R.id.tvRuntime); TextView runTimeHc = (TextView) findViewById(R.id.tvRuntimeHC); String runtimeText = ""; try { runtimeText = runtimeComputation(Float.parseFloat(movie.getRuntime())); } catch (Exception e) { runtimeText = movie.getRuntime(); } runtime.setText(runtimeText); manageEmptyTextfields(runTimeHc, runtime, runtimeText, true); TextView budget = (TextView) findViewById(R.id.tvBudget); TextView budgetHc = (TextView) findViewById(R.id.tvBudgetHC); String budgetText = movie.getBudget(); //Decode the budget if (budgetText.contains("E")) { BigDecimal myNumber = new BigDecimal(budgetText); long budgetLong = myNumber.longValue(); NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US); budgetText = formatter.format(budgetLong); budgetText = String.valueOf(budgetText); budgetText = budgetComputation(budgetText); budget.setText(budgetText); manageEmptyTextfields(budgetHc, budget, budgetText, true); } TextView awards = (TextView) findViewById(R.id.tvAwards); TextView awardsHc = (TextView) findViewById(R.id.tvAwardsHC); String awardsText = movie.getAwards(); awards.setText(awardsText); manageEmptyTextfields(awardsHc, awards, awardsText, true); TextView tvDirHc = (TextView) findViewById(R.id.tvDirectorsHC); TextView directors = (TextView) findViewById(R.id.tvDirectors); String directorText = String.valueOf(movie.createTvOutOfList(movie.getDirectors())); directors.setText(directorText); manageEmptyTextfields(tvDirHc, directors, directorText, true); TextView tvWriterHc = (TextView) findViewById(R.id.tvWritersHC); TextView writers = (TextView) findViewById(R.id.tvWriters); String writerText = String.valueOf(movie.createTvOutOfList(movie.getWriters())); writers.setText(writerText); manageEmptyTextfields(tvWriterHc, writers, writerText, true); TextView tvActorsHc = (TextView) findViewById(R.id.tvActorsHC); TextView actors = (TextView) findViewById(R.id.tvActors); String actorText = String.valueOf(movie.createTvOutOfList(movie.getActors())); actors.setText(actorText); manageEmptyTextfields(tvActorsHc, actors, actorText, true); colorIt(actors); if (movie.getActors().size() > 0) { btnActorList.setVisibility(View.VISIBLE); } btnRandomRelatedMovies.setVisibility(View.VISIBLE); btnRelatedMovies.setVisibility(View.VISIBLE); TextView tvRolesHc = (TextView) findViewById(R.id.tvRolesHC); TextView roles = (TextView) findViewById(R.id.tvRoles); ArrayList<String> roleList = movie.getRoles(); if (roleList.size() > 0) { roles.setVisibility(View.VISIBLE); tvRolesHc.setVisibility(View.VISIBLE); roles.setText(String.valueOf(movie.createTvOutOfList(roleList))); } TextView wikiAbstract = (TextView) findViewById(R.id.tvWikiAbstract); wikiAbstract.setText(movie.getWikiAbstract()); if (!"".equals(movie.getImdbId())) { btnImdbPage.setVisibility(View.VISIBLE); } if (!"".equals(movie.getWikiAbstract())) { btnSpoiler.setVisibility(View.VISIBLE); } try { picThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } setProgressBarIndeterminateVisibility(false); }
From source file:net.naonedbus.fragment.CustomListFragment.java
/** * Afficher un message avec une desciption et un symbole. * /*from ww w . j a va2 s . co m*/ * @param title * Le titre. * @param description * La description. * @param drawableRes * L'identifiant du symbole. */ protected void showMessage(final String title, final String description, final int drawableRes) { if (State.MESSAGE == mCurrentState) { return; } if (DBG) Log.d(LOG_TAG + "$" + getClass().getSimpleName(), "showMessage " + title + "\t" + description + "\t" + drawableRes); mCurrentState = State.MESSAGE; mFragmentView.findViewById(android.R.id.list).setVisibility(View.GONE); mFragmentView.findViewById(R.id.fragmentLoading).setVisibility(View.GONE); View message = mFragmentView.findViewById(R.id.fragmentMessage); if (message == null) { final ViewStub messageStrub = (ViewStub) mFragmentView.findViewById(R.id.fragmentMessageStub); message = messageStrub.inflate(); } message.setVisibility(View.VISIBLE); final TextView titleView = (TextView) message.findViewById(android.R.id.title); titleView.setText(title); titleView.setCompoundDrawablesWithIntrinsicBounds(0, drawableRes, 0, 0); final TextView descriptionView = (TextView) message.findViewById(android.R.id.summary); if (description != null) { descriptionView.setText(description); descriptionView.setVisibility(View.VISIBLE); } else { descriptionView.setVisibility(View.GONE); } }
From source file:cf.obsessiveorange.rhcareerfairlayout.ui.fragments.VPCompaniesFragment.java
@Override public void onResume() { companySelectionChangedWatcher = new Thread(new Runnable() { @Override/* ww w . jav a 2s . c o m*/ public void run() { try { while (!Thread.currentThread().isInterrupted()) { synchronized (RHCareerFairLayout.refreshCompaniesNotifier) { if (!RHCareerFairLayout.refreshCompaniesNotifier.hasChanged()) { RHCareerFairLayout.refreshCompaniesNotifier.wait(); if (!RHCareerFairLayout.refreshCompaniesNotifier.hasChanged()) { continue; } } } ((CompaniesCellAdapter) recyclerView.getAdapter()).refreshData(); final String searchText = ((MainActivity) getActivity()).getSearchString(); final TextView notificationTextView = (TextView) mView .findViewById(R.id.companies_txt_notificationBox); getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (searchText != null && !searchText.isEmpty()) { notificationTextView.setText( getResources().getString(R.string.notification_Search, searchText)); notificationTextView.setVisibility(View.VISIBLE); } else { notificationTextView.setVisibility(View.GONE); } } }); synchronized (RHCareerFairLayout.refreshMapNotifier) { RHCareerFairLayout.refreshMapNotifier.notifyChanged(); } } Log.d(RHCareerFairLayout.RH_CFL, "companySelectionChangedWatcher thread stopped."); companySelectionChangedWatcher = null; } catch (InterruptedException e) { Log.d(RHCareerFairLayout.RH_CFL, "companySelectionChangedWatcher thread stopped."); companySelectionChangedWatcher = null; } } }); companySelectionChangedWatcher.start(); super.onResume(); }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
/** * Implementation of SearchMessageHandler.OnMessageHandledListener *///from ww w. jav a 2 s .co m @Override public void OnMessageHandled(Message msg) { final Bundle b = msg.getData(); mView.findViewById(R.id.details_progress_address).setVisibility(View.GONE); if (b.getInt(Const.KEY_BUNDLE_REVERSE_GEOCODER) == Const.BUNDLE_SEARCH_ADDRESS_SUCCESS) { TextView addressUi = (TextView) mView.findViewById(R.id.details_address); final String desc = b.getString(Const.KEY_BUNDLE_ADDRESS_DESC); addressUi.setText(desc); addressUi.setVisibility(View.VISIBLE); final int indexOfSeparator = desc.indexOf(Const.LINE_SEPARATOR); if (indexOfSeparator > 0) { mFavoriteLabel = desc.substring(0, indexOfSeparator); } else { mFavoriteLabel = desc; } } else { /** * Address not found! Display error message. */ try { ((ParkingApp) getActivity().getApplicationContext()).showToastText(R.string.toast_address_error, Toast.LENGTH_SHORT); } catch (NullPointerException e) { e.printStackTrace(); } } }
From source file:com.android.tv.menu.MenuLayoutManager.java
private void setTempTitleView(TextView dest, TextView src) { dest.setVisibility(View.VISIBLE); dest.setText(src.getText());/* w w w . ja v a2 s . co m*/ dest.setTranslationY(0.0f); if (src.getVisibility() == View.VISIBLE) { dest.setAlpha(src.getAlpha()); dest.setScaleX(src.getScaleX()); dest.setScaleY(src.getScaleY()); } else { dest.setAlpha(0.0f); dest.setScaleX(1.0f); dest.setScaleY(1.0f); } View parent = (View) src.getParent(); dest.setLeft(src.getLeft() + parent.getLeft()); dest.setRight(src.getRight() + parent.getLeft()); dest.setTop(src.getTop() + parent.getTop()); dest.setBottom(src.getBottom() + parent.getTop()); }
From source file:com.concentricsky.android.khanacademy.data.remote.KAAPIAdapter.java
/** * Call me from the UI thread, please.//from w ww . j a va 2s . c o m * * Meant for use by broadcast receivers receiving ACTION_BADGE_EARNED. * */ public void toastBadge(Badge badge) { BadgeCategory category = badge.getCategory(); // Dao<BadgeCategory, Integer> dao = dataService.getHelper().getDao(BadgeCategory.class); // dao.refresh(category); Toast toast = new Toast(dataService); View content = LayoutInflater.from(dataService).inflate(R.layout.badge, null, false); ImageView iconView = (ImageView) content.findViewById(R.id.badge_image); TextView pointsView = (TextView) content.findViewById(R.id.badge_points); TextView titleView = (TextView) content.findViewById(R.id.badge_title); TextView descView = (TextView) content.findViewById(R.id.badge_description); iconView.setImageResource(category.getIconResourceId()); int points = badge.getPoints(); if (points > 0) { pointsView.setText(points + ""); } else { pointsView.setVisibility(View.GONE); } titleView.setText(badge.getDescription()); descView.setText(badge.getSafe_extended_description()); toast.setView(content); toast.setDuration(Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP, 0, 200); toast.show(); }
From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java
/** * Override methods / listeners/*from ww w. j a v a 2 s . com*/ */ @Override public Object instantiateItem(ViewGroup container, int position) { SwipeItem slideItem = mItems.get(position); LinearLayout layout = null; switch (slideItem.iconGravity) { case CENTER: case DEFAULT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_item, null); break; case LEFT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_left_item, null); break; case RIGHT: layout = (LinearLayout) View.inflate(mContext, R.layout.swipeselector_content_right_item, null); break; } // GET VIEW ImageView icon = (ImageView) layout.findViewById(R.id.swipeselector_content_icon); TextView title = (TextView) layout.findViewById(R.id.swipeselector_content_title); TextView description = (TextView) layout.findViewById(R.id.swipeselector_content_description); // SET VIEW title.setText(slideItem.title); if (slideItem.description == null) { description.setVisibility(View.GONE); } else { description.setVisibility(View.VISIBLE); description.setText(slideItem.description); } if (slideItem.icon == null) { icon.setVisibility(View.GONE); } else { icon.setImageDrawable(slideItem.icon); icon.setVisibility(View.VISIBLE); } // We shouldn't get here if the typeface didn't exist. // But just in case, because we're paranoid. if (mCustomTypeFace != null) { title.setTypeface(mCustomTypeFace); description.setTypeface(mCustomTypeFace); } if (mTitleTextAppearance != -1) { setTextAppearanceCompat(title, mTitleTextAppearance); } if (mDescriptionTextAppearance != -1) { setTextAppearanceCompat(description, mDescriptionTextAppearance); } switch (slideItem.titleGravity) { case DEFAULT: case CENTER: title.setGravity(Gravity.CENTER); break; case LEFT: title.setGravity(Gravity.START); break; case RIGHT: title.setGravity(Gravity.END); break; } switch (slideItem.descriptionGravity) { case DEFAULT: if (mDescriptionGravity != -1) { description.setGravity(mDescriptionGravity); } else { description.setGravity(Gravity.CENTER); } break; case CENTER: description.setGravity(Gravity.CENTER); break; case LEFT: description.setGravity(Gravity.START); break; case RIGHT: description.setGravity(Gravity.END); break; } layout.setPadding(mContentLeftPadding, mSweetSixteen, mContentRightPadding, mSweetSixteen); container.addView(layout); return layout; }