List of usage examples for android.widget ImageView setContentDescription
@RemotableViewMethod public void setContentDescription(CharSequence contentDescription)
From source file:uk.ac.horizon.artcodes.scanner.ScannerActivity.java
private void createSettingsUI(List<DetectorSetting> settings) { settingIcons.removeAllViews();/*from www .j a va 2 s . co m*/ if (settings != null && !settings.isEmpty()) { final int padding = getResources().getDimensionPixelSize(R.dimen.setting_padding); List<DetectorSetting> settingList = settings; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { settingList = Lists.reverse(settings); } for (final DetectorSetting setting : settingList) { final ImageView button = new ImageView(this); button.setContentDescription(getString(setting.getText())); final int[] attrs = new int[] { android.R.attr.selectableItemBackground }; final TypedArray ta = obtainStyledAttributes(attrs); final Drawable drawableFromTheme = ta.getDrawable(0); ta.recycle(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { button.setImageResource(setting.getIcon()); button.setImageTintList(ColorStateList.valueOf(Color.WHITE)); button.setBackground(drawableFromTheme); } else { button.setImageDrawable(getTintedDrawable(setting.getIcon(), Color.WHITE)); //noinspection deprecation button.setBackgroundDrawable(drawableFromTheme); } button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setting.nextValue(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { button.setImageResource(setting.getIcon()); } else { button.setImageDrawable(getTintedDrawable(setting.getIcon(), Color.WHITE)); } button.setContentDescription(getString(setting.getText())); textAnimator.setText(setting.getText()); } }); final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1); params.weight = 1; button.setLayoutParams(params); settingIcons.addView(button); button.setPadding(padding, padding, padding, padding); } } menuAnimator.setViewVisible(settingIcons.getChildCount() > 0); }
From source file:org.totschnig.myexpenses.dialog.HelpDialogFragment.java
/** * @param menuItems list of menuitems to be displayed * @param prefix "form", "menu" or "cab" * @param offset items will be added with this offset at the bottom * @throws NotFoundException/* www.j a v a 2 s.co m*/ */ protected void handleMenuItems(ArrayList<String> menuItems, String prefix, int offset) throws NotFoundException { String resIdString; int resId; for (String item : menuItems) { View row = layoutInflater.inflate(R.layout.help_dialog_action_row, linearLayout, false); String title = ""; if (prefix.equals("form")) { //this allows us to map an item like "date.time" to the concatenation of translations for date and for time for (String resIdPart : item.split("\\.")) { if (!title.equals("")) title += "/"; title += resolveStringOrThrowIf0(resIdPart); } } else { title = resolveStringOrThrowIf0("menu_" + item); } ((TextView) row.findViewById(R.id.title)).setText(title); if (prefix.equals("form")) { row.findViewById(R.id.list_image_container).setVisibility(View.GONE); } else if (iconMap.containsKey(item)) { resId = iconMap.get(item); final ImageView icon = (ImageView) row.findViewById(R.id.list_image); icon.setVisibility(View.VISIBLE); icon.setImageResource(resId); icon.setContentDescription(title); } else { //for the moment we assume that menu entries without icon are checkable row.findViewById(R.id.list_checkbox).setVisibility(View.VISIBLE); } //we look for a help text specific to the variant first, then to the activity //and last a generic one //We look for an array first, which allows us to compose messages of parts CharSequence helpText; helpText = resolveStringOrArray(prefix + "_" + context + "_" + variant + "_" + item + "_help_text"); if (TextUtils.isEmpty(helpText)) { helpText = resolveStringOrArray(prefix + "_" + context + "_" + item + "_help_text"); if (TextUtils.isEmpty(helpText)) { resIdString = prefix + "_" + item + "_help_text"; helpText = resolveStringOrArray(resIdString); if (TextUtils.isEmpty(helpText)) { throw new NotFoundException(resIdString); } } } ((TextView) row.findViewById(R.id.help_text)).setText(helpText); linearLayout.addView(row, linearLayout.getChildCount() - offset); } }
From source file:mx.udlap.is522.tedroid.fragment.InstructionsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_instructions, container, false); ImageView instructionImage = (ImageView) rootView.findViewById(R.id.instruction_image); TextView instructionText = (TextView) rootView.findViewById(R.id.instruction_text); int instructionImageContentDescriptionId = getTextByPageNumber(); if (instructionImageContentDescriptionId != NOT_AN_ID) { Typeface typeface = Typefaces.get(getActivity(), Typefaces.Font.TWOBIT); instructionText.setText(instructionImageContentDescriptionId); instructionText.setTypeface(typeface); instructionImage.setContentDescription(getString(instructionImageContentDescriptionId)); }/*from www.ja va2 s . co m*/ int instructionImageDrawableId = getDrawableByPageNumber(); if (instructionImageDrawableId != NOT_AN_ID) instructionImage.setImageResource(instructionImageDrawableId); return rootView; }
From source file:dk.nordfalk.aktivitetsliste.PagerSlidingTabStrip.java
private void addIconTabBdeTekstOgBillede(final int position, int resId, String title) { FrameLayout tabfl = new FrameLayout(getContext()); ImageView tabi = new ImageView(getContext()); tabi.setContentDescription(title); tabi.setImageResource(resId);/*from w w w . j av a 2s . c om*/ tabi.setVisibility(View.INVISIBLE); TextView tabt = new TextView(getContext()); tabt.setText(title); tabt.setGravity(Gravity.CENTER); tabt.setSingleLine(); tabfl.addView(tabi); tabfl.addView(tabt); LayoutParams lp = (LayoutParams) tabi.getLayoutParams(); lp.gravity = Gravity.CENTER; lp = (LayoutParams) tabt.getLayoutParams(); lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT; lp.gravity = Gravity.CENTER; addTab(position, tabfl); }
From source file:dk.dr.radio.diverse.PagerSlidingTabStrip.java
private void addIconTabBdeTekstOgBillede(final int position, int resId, String title) { FrameLayout tabfl = new FrameLayout(getContext()); ImageView tabi = new ImageView(getContext()); tabi.setContentDescription(title); tabi.setImageResource(resId);//from w w w . j a v a 2s .c o m tabi.setVisibility(View.INVISIBLE); TextView tabt = new TextView(getContext()); tabt.setText(title); tabt.setTypeface(App.skrift_gibson); tabt.setGravity(Gravity.CENTER); tabt.setSingleLine(); tabfl.addView(tabi); tabfl.addView(tabt); LayoutParams lp = (LayoutParams) tabi.getLayoutParams(); lp.gravity = Gravity.CENTER; lp = (LayoutParams) tabt.getLayoutParams(); lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT; lp.gravity = Gravity.CENTER; addTab(position, tabfl); }
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 .j a v a 2s . com*/ 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.joravasal.comicagg.ComicDetailFragment.java
@SuppressLint({ "NewApi" }) @Override// w w w . j a va2 s .c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_comic_detail, container, false); if (comicItem == null && savedInstanceState.containsKey(ARG_ITEM_ID)) { comicItem = new ComicItem(savedInstanceState.getString(ARG_ITEM_ID), savedInstanceState.getString("comicname"), savedInstanceState.getString("comicurl"), savedInstanceState.getString("unreadcount")); } int unread = Integer.parseInt(comicItem.unreadCount); if (unread == 0) { rootView.findViewById(R.id.vote_bar).setVisibility(View.GONE); } LinearLayout stripList = (LinearLayout) rootView.findViewById(R.id.strips_list); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); if (comicItem.id.equals(ComicStripsContent.id) && ComicStripsContent.ITEMS.size() > unread) { unread = ComicStripsContent.ITEMS.size(); } for (int i = 1; i < unread; i++) { ImageView iv = new ImageView(getActivity()); iv.setId(Integer.MAX_VALUE - i); iv.setPadding(16, 16, 16, 0); iv.setContentDescription(getString(R.string.strip_description)); iv.setAdjustViewBounds(true); iv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO check if there is need of opening? or always open? openFullscreenStrip(v); } }); TextView tv = new TextView(getActivity()); tv.setId(i); tv.setPadding(16, 4, 16, 4); tv.setGravity(Gravity.CENTER); stripList.addView(iv, layoutParams); stripList.addView(tv, layoutParams); } if (!comicItem.id.equals(ComicStripsContent.id)) { new GetComicsStrips(comicItem.id, unread, rootView).execute(); } else { new GetComicsStrips(comicItem.id, unread, rootView).onPostExecute(null); } if (savedInstanceState != null && savedInstanceState.containsKey(VERTICAL_SCROLLING_POSITION) && VERSION.SDK_INT >= 14) { rootView.findViewById(R.id.comic_scrollView).scrollTo(0, savedInstanceState.getInt(VERTICAL_SCROLLING_POSITION)); } return rootView; }
From source file:com.android.deskclock.stopwatch.StopwatchFragment.java
@Override public void onUpdateFab(@NonNull ImageView fab) { if (getStopwatch().isRunning()) { fab.setImageResource(R.drawable.ic_pause_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.sw_pause_button)); } else {//from w w w . jav a2s .c o m fab.setImageResource(R.drawable.ic_start_white_24dp); fab.setContentDescription(fab.getResources().getString(R.string.sw_start_button)); } fab.setVisibility(VISIBLE); }
From source file:com.wizardsofm.deskclock.stopwatch.StopwatchFragment.java
@Override public void onUpdateFab(@NonNull ImageView fab) { if (getStopwatch().isRunning()) { fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_pause_white_24dp); fab.setContentDescription( fab.getResources().getString(com.wizardsofm.deskclock.R.string.sw_pause_button)); } else {/*w ww . j a v a2 s.co m*/ fab.setImageResource(com.wizardsofm.deskclock.R.drawable.ic_start_white_24dp); fab.setContentDescription( fab.getResources().getString(com.wizardsofm.deskclock.R.string.sw_start_button)); } fab.setVisibility(VISIBLE); }
From source file:com.surinov.alexander.wallet2wallet.views.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { ImageView tabView = crateDefaultImageView(getContext()); if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0;//from w w w .j a va2 s . c o m lp.weight = 1; } tabView.setImageResource(((FragmentAdapter) adapter).getDrawableResource(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }