List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:com.davisosa.structura.activities.base.BaseActivity.java
private View createDrawerItem(final int itemId, ViewGroup container) { boolean selected = getSelfDrawerItem() == itemId; int layout;/*from ww w . j ava 2s . com*/ if (itemId == DRAWER_ITEM_SEPARATOR) { layout = R.layout.drawer_separator; } else if (itemId == DRAWER_ITEM_SEPARATOR_SPECIAL) { layout = R.layout.drawer_separator; } else { layout = R.layout.drawer_item; } View view = getLayoutInflater().inflate(layout, container, false); if (isSeparator(itemId)) { // We're done. UIUtils.setAccessibilityIgnore(view); return view; } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); int iconId = itemId >= 0 && itemId < RES_IDS_DRAWER_ICON.length ? RES_IDS_DRAWER_ICON[itemId] : 0; int titleId = itemId >= 0 && itemId < RES_IDS_DRAWER_TITLE.length ? RES_IDS_DRAWER_TITLE[itemId] : 0; // Set icon and text. if (iconId > 0) { iconView.setVisibility(View.VISIBLE); iconView.setImageResource(iconId); } else { iconView.setVisibility(View.INVISIBLE); } titleView.setText(getString(titleId)); formatDrawerItem(view, itemId, selected); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onDrawerItemClicked(itemId); } }); return view; }
From source file:com.qbgg.cenglaicengqu.common.ui.viewpager.PagerSlidingTabStrip.java
public void updateTab(int index, com.qbgg.cenglaicengqu.main.reminder.ReminderItem item) { LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index); ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator); TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label); if (item == null || unreadLbl == null || indicatorView == null) { unreadLbl.setVisibility(View.GONE); indicatorView.setVisibility(View.GONE); return;/*from www . j a v a 2 s .co m*/ } int unread = item.unread(); boolean indicator = item.indicator(); unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE); indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE); if (unread > 0) { unreadLbl.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread))); } }
From source file:de.baumann.browser.popups.Popup_bookmarks.java
private void setBookmarksList() { //display data final int layoutstyle = R.layout.list_item; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "bookmarks_title", "bookmarks_content", "bookmarks_creation" }; final Cursor row = db.fetchAllData(this); adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0) { @Override// w w w . ja v a 2 s .c om public View getView(final int position, View convertView, ViewGroup parent) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row2 .getString(row2.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation")); View v = super.getView(position, convertView, parent); final ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes); switch (bookmarks_attachment) { case "": iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_outline); break; default: iv_attachment.setVisibility(View.VISIBLE); iv_attachment.setImageResource(R.drawable.star_grey); break; } iv_attachment.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (bookmarks_attachment.equals("")) { if (db.isExistFav("true")) { Snackbar.make(listView, R.string.bookmark_setFav_not, Snackbar.LENGTH_LONG).show(); } else { iv_attachment.setImageResource(R.drawable.star_grey); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "true", bookmarks_creation); setBookmarksList(); sharedPref.edit().putString("startURL", bookmarks_content).apply(); Snackbar.make(listView, R.string.bookmark_setFav, Snackbar.LENGTH_LONG).show(); } } else { iv_attachment.setImageResource(R.drawable.star_outline); db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "", bookmarks_creation); setBookmarksList(); } } }); return v; } }; //display data by filter final String note_search = sharedPref.getString("filter_bookmarksBY", "bookmarks_title"); sharedPref.edit().putString("filter_bookmarksBY", "bookmarks_title").apply(); editText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s.toString()); } }); adapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { return db.fetchDataByFilter(constraint.toString(), note_search); } }); listView.setAdapter(adapter); //onClick function listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row = (Cursor) listView.getItemAtPosition(position); final String bookmarks_content = row.getString(row.getColumnIndexOrThrow("bookmarks_content")); sharedPref.edit().putString("openURL", bookmarks_content).apply(); finish(); } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title")); final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content")); final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon")); final String bookmarks_attachment = row2 .getString(row2.getColumnIndexOrThrow("bookmarks_attachment")); final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation")); final CharSequence[] options = { getString(R.string.menu_share), getString(R.string.menu_save), getString(R.string.bookmark_edit_title), getString(R.string.bookmark_remove_bookmark) }; new AlertDialog.Builder(Popup_bookmarks.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.bookmark_edit_title))) { sharedPref.edit().putString("edit_id", _id).apply(); sharedPref.edit().putString("edit_content", bookmarks_content).apply(); sharedPref.edit().putString("edit_icon", bookmarks_icon).apply(); sharedPref.edit().putString("edit_attachment", bookmarks_attachment).apply(); sharedPref.edit().putString("edit_creation", bookmarks_creation).apply(); editText.setVisibility(View.VISIBLE); helper_editText.showKeyboard(Popup_bookmarks.this, editText, 2, bookmarks_title, getString(R.string.bookmark_edit_title)); } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(listView, R.string.bookmark_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setBookmarksList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.menu_share))) { final CharSequence[] options = { getString(R.string.menu_share_link), getString(R.string.menu_share_link_copy) }; new AlertDialog.Builder(Popup_bookmarks.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }) .setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.menu_share_link))) { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, bookmarks_title); sharingIntent.putExtra(Intent.EXTRA_TEXT, bookmarks_content); startActivity(Intent.createChooser(sharingIntent, (getString(R.string.app_share_link)))); } if (options[item] .equals(getString(R.string.menu_share_link_copy))) { ClipboardManager clipboard = (ClipboardManager) Popup_bookmarks.this .getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip( ClipData.newPlainText("text", bookmarks_content)); Snackbar.make(listView, R.string.context_linkCopy_toast, Snackbar.LENGTH_SHORT).show(); } } }).show(); } if (options[item].equals(getString(R.string.menu_save))) { final CharSequence[] options = { getString(R.string.menu_save_readLater), getString(R.string.menu_save_pass), getString(R.string.menu_createShortcut) }; new AlertDialog.Builder(Popup_bookmarks.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }) .setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.menu_save_pass))) { helper_editText.editText_savePass(Popup_bookmarks.this, listView, bookmarks_title, bookmarks_content); } if (options[item] .equals(getString(R.string.menu_save_readLater))) { DbAdapter_ReadLater db = new DbAdapter_ReadLater( Popup_bookmarks.this); db.open(); if (db.isExist(bookmarks_content)) { Snackbar.make(editText, getString(R.string.toast_newTitle), Snackbar.LENGTH_LONG).show(); } else { db.insert(bookmarks_title, bookmarks_content, "", "", helper_main.createDate()); Snackbar.make(listView, R.string.bookmark_added, Snackbar.LENGTH_LONG).show(); } } if (options[item] .equals(getString(R.string.menu_createShortcut))) { Intent i = new Intent(); i.setAction(Intent.ACTION_VIEW); i.setClassName(Popup_bookmarks.this, "de.baumann.browser.Browser_left"); i.setData(Uri.parse(bookmarks_content)); Intent shortcut = new Intent(); shortcut.putExtra("android.intent.extra.shortcut.INTENT", i); shortcut.putExtra("android.intent.extra.shortcut.NAME", "THE NAME OF SHORTCUT TO BE SHOWN"); shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, bookmarks_title); shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext( Popup_bookmarks.this .getApplicationContext(), R.mipmap.ic_launcher)); shortcut.setAction( "com.android.launcher.action.INSTALL_SHORTCUT"); Popup_bookmarks.this.sendBroadcast(shortcut); Snackbar.make(listView, R.string.menu_createShortcut_success, Snackbar.LENGTH_SHORT).show(); } } }).show(); } } }).show(); return true; } }); }
From source file:cm.confide.ex.chips.RecipientAlternatesAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { int position = cursor.getPosition(); TextView display = (TextView) view.findViewById(android.R.id.title); ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); RecipientEntry entry = getRecipientEntry(position); if (position == 0) { display.setText(cursor.getString(Queries.Query.NAME)); display.setVisibility(View.VISIBLE); // TODO: see if this needs to be done outside the main thread // as it may be too slow to get immediately. imageView.setImageURI(entry.getPhotoThumbnailUri()); imageView.setVisibility(View.VISIBLE); } else {// w w w. j a v a 2s . co m display.setVisibility(View.GONE); imageView.setVisibility(View.GONE); } TextView destination = (TextView) view.findViewById(android.R.id.text1); destination.setText(cursor.getString(Queries.Query.DESTINATION)); TextView destinationType = (TextView) view.findViewById(android.R.id.text2); if (destinationType != null) { destinationType.setText( mQuery.getTypeLabel(context.getResources(), cursor.getInt(Queries.Query.DESTINATION_TYPE), cursor.getString(Queries.Query.DESTINATION_LABEL)).toString().toUpperCase()); } }
From source file:com.cloudTop.starshare.ui.wangyi.common.ui.viewpager.PagerSlidingTabStrip.java
public void updateTab(int index, ReminderItem item) { LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index); ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator); final DropFake unreadTV = ((DropFake) tabView.findViewById(R.id.tab_new_msg_label)); if (item == null || unreadTV == null || indicatorView == null) { unreadTV.setVisibility(View.GONE); indicatorView.setVisibility(View.GONE); return;//from w w w . j a v a2 s .c o m } int unread = item.unread(); boolean indicator = item.indicator(); unreadTV.setVisibility(unread > 0 ? View.VISIBLE : View.GONE); indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE); if (unread > 0) { unreadTV.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread))); } }
From source file:org.thialfihar.android.apg.ui.adapter.ViewKeyKeysAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { TextView keyId = (TextView) view.findViewById(R.id.keyId); TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails); ImageView masterKeyIcon = (ImageView) view.findViewById(R.id.ic_masterKey); ImageView certifyIcon = (ImageView) view.findViewById(R.id.ic_certifyKey); ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey); ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey); ImageView revokedKeyIcon = (ImageView) view.findViewById(R.id.ic_revokedKey); String keyIdStr = PgpKeyHelper.convertKeyIdToHexShort(cursor.getLong(mIndexKeyId)); String algorithmStr = PgpKeyHelper.getAlgorithmInfo(cursor.getInt(mIndexAlgorithm), cursor.getInt(mIndexKeySize)); keyId.setText(keyIdStr);//from ww w . j a va 2 s . co m keyDetails.setText("(" + algorithmStr + ")"); if (cursor.getInt(mIndexIsMasterKey) != 1) { masterKeyIcon.setVisibility(View.INVISIBLE); } else { masterKeyIcon.setVisibility(View.VISIBLE); } if (cursor.getInt(mIndexCanCertify) != 1) { certifyIcon.setVisibility(View.GONE); } else { certifyIcon.setVisibility(View.VISIBLE); } if (cursor.getInt(mIndexCanEncrypt) != 1) { encryptIcon.setVisibility(View.GONE); } else { encryptIcon.setVisibility(View.VISIBLE); } if (cursor.getInt(mIndexCanSign) != 1) { signIcon.setVisibility(View.GONE); } else { signIcon.setVisibility(View.VISIBLE); } if (cursor.getInt(mIndexRevokedKey) > 0) { revokedKeyIcon.setVisibility(View.VISIBLE); keyId.setTextColor(Color.RED); keyDetails.setTextColor(Color.RED); } else { keyId.setTextColor(mDefaultTextColor); keyDetails.setTextColor(mDefaultTextColor); revokedKeyIcon.setVisibility(View.GONE); } }
From source file:org.puder.trs80.EmulatorActivity.java
private void initRootView() { setContentView(R.layout.emulator);/*w w w. j a v a 2s .com*/ View top = this.findViewById(R.id.emulator); top.setFocusable(true); top.setFocusableInTouchMode(true); top.requestFocus(); logView = (TextView) findViewById(R.id.log); if (CastMessageSender.get().isReadyToSend()) { ImageView castIcon = (ImageView) findViewById(R.id.cast_icon); castIcon.setVisibility(View.VISIBLE); } else { Screen screen = (Screen) findViewById(R.id.screen); screen.setVisibility(View.VISIBLE); } initKeyboardView(); }
From source file:com.ffmpeger.card.ui.BaseNaviActivity.java
private View makeNavDrawerItem(final int itemId, ViewGroup container) { boolean selected = getSelfNavDrawerItem() == itemId; int layoutToInflate = 0; if (itemId == NAVDRAWER_ITEM_SEPARATOR) { layoutToInflate = R.layout.navdrawer_separator; } else if (itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL) { layoutToInflate = R.layout.navdrawer_separator; } else {/*from w ww . j av a2s .c o m*/ layoutToInflate = R.layout.navdrawer_item; } View view = getLayoutInflater().inflate(layoutToInflate, container, false); if (isSeparator(itemId)) { // we are done //UIUtils.setAccessibilityIgnore(view); return view; } ImageView iconView = (ImageView) view.findViewById(R.id.icon); TextView titleView = (TextView) view.findViewById(R.id.title); int iconId = itemId >= 0 && itemId < NAVDRAWER_ICON_RES_ID.length ? NAVDRAWER_ICON_RES_ID[itemId] : 0; int titleId = itemId >= 0 && itemId < NAVDRAWER_TITLE_RES_ID.length ? NAVDRAWER_TITLE_RES_ID[itemId] : 0; // set icon and text iconView.setVisibility(iconId > 0 ? View.VISIBLE : View.GONE); if (iconId > 0) { iconView.setImageResource(iconId); } titleView.setText(getString(titleId)); formatNavDrawerItem(view, itemId, selected); view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onNavDrawerItemClicked(itemId); } }); return view; }
From source file:com.google.samples.apps.iosched.navigation.AppNavigationViewAsDrawerImpl.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that shows * which account the user is logged in as, and lets them switch accounts. It also shows the * user's Google+ cover photo as background. *//* w w w .j ava2 s . c o m*/ private void setupAccountBox() { final View chosenAccountView = mActivity.findViewById(R.id.chosen_account_view); if (chosenAccountView == null) { //This activity does not have an account box return; } Account chosenAccount = AccountUtils.getActiveAccount(mActivity); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); } ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); String imageUrl = AccountUtils.getPlusImageUrl(mActivity); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(mActivity); if (coverImageUrl != null) { mActivity.findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.GONE); coverImageView.setVisibility(View.VISIBLE); coverImageView.setContentDescription( mActivity.getResources().getString(R.string.navview_header_user_image_content_description)); mImageLoader.loadImage(coverImageUrl, coverImageView); coverImageView.setColorFilter(mActivity.getResources().getColor(R.color.light_content_scrim)); } else { mActivity.findViewById(R.id.profile_cover_image_placeholder).setVisibility(View.VISIBLE); coverImageView.setVisibility(View.GONE); } List<Account> accounts = Arrays.asList(AccountUtils.getActiveAccount(getContext())); populateAccountList(accounts); }
From source file:play.wm.ljb.com.wmiplay.view.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (pager.getAdapter() instanceof IconTextTabProvider) { ImageView tab_image = (ImageView) v.findViewById(R.id.tab_iamge); TextView tab_text = (TextView) v.findViewById(R.id.tab_text); if (mSelectPosititon == i) { tab_image.setImageResource(((IconTextTabProvider) pager.getAdapter()).getPageIconTextResId(i)); tab_image.setVisibility(View.VISIBLE); tab_text.setVisibility(View.INVISIBLE); } else { tab_text.setText(pager.getAdapter().getPageTitle(i)); tab_text.setVisibility(View.VISIBLE); tab_image.setVisibility(View.INVISIBLE); }/* w w w . ja va 2 s. c om*/ } else if (pager.getAdapter() instanceof IconTabProvider) { //TODO } else { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); if (mSelectPosititon == i) { tab.setTextColor(XgoUIUtils.getColor(R.color.indicatorcolor)); } else { tab.setTextColor(tabTextColor); } // setAllCaps() is only available from API 14, so the upper case // is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } } } }