List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:com.example.android.Spanish.WordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }/*from ww w . j a v a 2s . co m*/ // Get the {@link Word} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID miwok_text_view. TextView miwokTextView = (TextView) listItemView.findViewById(R.id.miwok_text_view); // Get the Miwok translation from the currentWord object and set this text on // the Miwok TextView. miwokTextView.setText(currentWord.getSpanishTranslation()); // Find the TextView in the list_item.xml layout with the ID default_text_view. TextView defaultTextView = (TextView) listItemView.findViewById(R.id.default_text_view); // Get the default translation from the currentWord object and set this text on // the default TextView. defaultTextView.setText(currentWord.getDefaultTranslation()); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); // Check if an image is provided for this word or not if (currentWord.hasImage()) { // If an image is available, display the provided image based on the resource ID imageView.setImageResource(currentWord.getImageResourceId()); // Make sure the view is visible imageView.setVisibility(View.VISIBLE); } else { // Otherwise hide the ImageView (set visibility to GONE) imageView.setVisibility(View.GONE); } // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that the resource ID maps to int color = ContextCompat.getColor(getContext(), mColorResourceId); // Set the background color of the text container View textContainer.setBackgroundColor(color); // Return the whole list item layout (containing 2 TextViews) so that it can be shown in // the ListView. return listItemView; }
From source file:com.example.android.tourguide.WordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }// w w w . j ava 2s .c o m // Get the {@link Word} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID miwok_text_view. TextView miwokTextView = (TextView) listItemView.findViewById(R.id.tourguide_text_view); // Get the Miwok translation from the currentWord object and set this text on // the Miwok TextView. miwokTextView.setText(currentWord.getMiwokTranslation()); // Find the TextView in the list_item.xml layout with the ID default_text_view. TextView defaultTextView = (TextView) listItemView.findViewById(R.id.default_text_view); // Get the default translation from the currentWord object and set this text on // the default TextView. defaultTextView.setText(currentWord.getDefaultTranslation()); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); // Check if an image is provided for this word or not if (currentWord.hasImage()) { // If an image is available, display the provided image based on the resource ID imageView.setImageResource(currentWord.getImageResourceId()); // Make sure the view is visible imageView.setVisibility(View.VISIBLE); } else { // Otherwise hide the ImageView (set visibility to GONE) imageView.setVisibility(View.GONE); } // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that the resource ID maps to int color = ContextCompat.getColor(getContext(), mColorResourceId); // Set the background color of the text container View textContainer.setBackgroundColor(color); // Return the whole list item layout (containing 2 TextViews) so that it can be shown in // the ListView. return listItemView; }
From source file:com.example.shubh.miwok.WordAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false); }/*from w ww. j av a 2 s.c o m*/ // Get the {@link Word} object located at this position in the list Word currentWord = getItem(position); // Find the TextView in the list_item.xml layout with the ID miwok_text_view. TextView miwokTextView = (TextView) listItemView.findViewById(R.id.miwok_text_view); // Get the Miwok translation from the currentWord object and set this text on // the Miwok TextView. miwokTextView.setText(currentWord.getMiwokTranslation()); // Find the TextView in the list_item.xml layout with the ID default_text_view. TextView defaultTextView = (TextView) listItemView.findViewById(R.id.default_text_view); // Get the default translation from the currentWord object and set this text on // the default TextView. defaultTextView.setText(currentWord.getDefaultTranslation()); // Find the ImageView in the list_item.xml layout with the ID image. ImageView imageView = (ImageView) listItemView.findViewById(R.id.image); // Check if an image is provided for this word or not if (currentWord.hasImage()) { // If an image is available, display the provided image based on the resource ID imageView.setImageResource(currentWord.getImageResourceId()); // Make sure the view is visible imageView.setVisibility(View.VISIBLE); } else { // Otherwise hide the ImageView (set visibility to GONE) imageView.setVisibility(View.GONE); } // Set the theme color for the list item View textContainer = listItemView.findViewById(R.id.text_container); // Find the color that the resource ID maps to int color = ContextCompat.getColor(getContext(), mColorResourceId); // Set the background color of the text container View textContainer.setBackgroundColor(color); // Return the whole list item layout (containing 2 TextViews) so that it can be shown in // the ListView. return listItemView; }
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// w w w. j a va 2 s . c o 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:com.nxt.njitong.ContactlistActivity.java
public void initviews() { //super.onActivityCreated(savedInstanceState); //T??home???appcrash //if(savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) // return;// w w w . j a va 2 s. c om context = this; findViewById(R.id.back).setVisibility(View.VISIBLE); ((TextView) findViewById(R.id.message_title)).setText(getIntent().getStringExtra("type")); inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) findViewById(R.id.list); sidebar = (Sidebar) findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) findViewById(R.id.query); String strSearch = getResources().getString(R.string.search); query.setHint(strSearch); clearSearch = (ImageButton) findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); } }); // adapter adapter = new ContactAdapter(context, R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = DemoApplication.getInstance().getContactList().get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(context, NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(context, GroupsActivity.class)); } else { // demo?? startActivity(new Intent(context, ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) findViewById(R.id.iv_new_contact); addContactView.setVisibility(View.GONE); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(context, AddContactActivity.class)); } }); registerForContextMenu(listView); }
From source file:org.jraf.android.hellomundo.app.pickwebcam.WebcamAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { WebcamCursor c = (WebcamCursor) cursor; long id = c.getId(); TextView txtName = (TextView) ViewHolder.get(view, R.id.txtName); String name = c.getName();//from w w w .j ava2s . c om txtName.setText(name); WebcamType type = c.getType(); boolean isUserWebcam = type != null && type == WebcamType.USER; // Extend View conExtended = ViewHolder.get(view, R.id.conExtended); conExtended.setTag(id); View btnExtend = ViewHolder.get(view, R.id.btnExtend); btnExtend.setTag(conExtended); if (cursor.getPosition() == cursor.getCount() - 1) { btnExtend.setTag(R.id.lastItem, true); } else { btnExtend.setTag(R.id.lastItem, false); } btnExtend.setOnClickListener(mExtendOnClickListener); LayoutParams layoutParams = conExtended.getLayoutParams(); if (mExtendedIds.contains(id)) { layoutParams.height = mExtendedHeight; } else { layoutParams.height = 0; } // Thumbnail ImageView imgThumbnail = ViewHolder.get(view, R.id.imgThumbnail); if (isUserWebcam) { imgThumbnail.setImageResource(R.drawable.ic_thumbnail_user_defined); } else { imgThumbnail.setImageResource(0); Picasso picasso = Picasso.with(context); // picasso.setDebugging(true); picasso.load(c.getThumbUrl()) .resizeDimen(R.dimen.pickWebcam_item_imgThumbnail_widthHeight, R.dimen.pickWebcam_item_imgThumbnail_widthHeight) .centerCrop().placeholder(R.drawable.ic_thumbnail_bg).into(imgThumbnail); } // Location & time TextView txtLocationAndTime = ViewHolder.get(view, R.id.txtLocationAndTime); if (isUserWebcam) { txtLocationAndTime.setText(R.string.common_userDefined); } else { String location = c.getLocation(); String publicId = c.getPublicId(); boolean specialCam = Constants.SPECIAL_CAMS.contains(publicId); if (!specialCam) { location += " - " + getLocalTime(context, c.getTimezone()); } txtLocationAndTime.setText(location); } // Source url TextView txtSourceUrl = ViewHolder.get(view, R.id.txtSourceUrl); String sourceUrl; if (isUserWebcam) { sourceUrl = c.getUrl(); sourceUrl = sourceUrl.substring("http://".length()); int slashIdx = sourceUrl.indexOf('/'); if (slashIdx != -1) { sourceUrl = sourceUrl.substring(0, slashIdx); } } else { sourceUrl = c.getSourceUrl(); } txtSourceUrl.setText(context.getString(R.string.pickWebcam_source, sourceUrl)); txtSourceUrl.setTag(sourceUrl); txtSourceUrl.setOnClickListener(mSourceOnClickListener); // Exclude from random Boolean excludeRandom = c.getExcludeRandom(); boolean excludedFromRandom = excludeRandom != null && excludeRandom; View btnExcludeFromRandom = ViewHolder.get(view, R.id.btnExcludeFromRandom); btnExcludeFromRandom.setSelected(excludedFromRandom); btnExcludeFromRandom.setTag(id); btnExcludeFromRandom.setOnClickListener(mExcludeFromRandomOnClickListener); ImageView imgExcludedFromRandom = ViewHolder.get(view, R.id.imgExcludedFromRandom); if (excludedFromRandom) { imgExcludedFromRandom.setVisibility(View.VISIBLE); } else { imgExcludedFromRandom.setVisibility(View.GONE); } // Show on map / delete View btnShowOnMap = ViewHolder.get(view, R.id.btnShowOnMap); ImageView imgShowOnMap = ViewHolder.get(view, R.id.imgShowOnMap); TextView txtShowOnMap = ViewHolder.get(view, R.id.txtShowOnMap); if (isUserWebcam) { imgShowOnMap.setImageResource(R.drawable.ic_ext_delete); txtShowOnMap.setText(R.string.pickWebcam_delete); btnShowOnMap.setTag(id); btnShowOnMap.setOnClickListener(mDeleteOnClickListener); } else { imgShowOnMap.setImageResource(R.drawable.ic_ext_show_on_map); txtShowOnMap.setText(R.string.pickWebcam_showOnMap); String coordinates = c.getCoordinates(); if (coordinates == null) { btnShowOnMap.setEnabled(false); } else { btnShowOnMap.setEnabled(true); btnShowOnMap.setTag(R.id.coordinates, coordinates); btnShowOnMap.setTag(R.id.name, name); btnShowOnMap.setOnClickListener(mShowOnMapOnClickListener); } } View btnPreview = ViewHolder.get(view, R.id.btnPreview); btnPreview.setTag(id); btnPreview.setOnClickListener(mPreviewOnClickListener); // Current webcam View conMainItem = ViewHolder.get(view, R.id.conMainItem); conMainItem.setSelected(id == mCurrentWebcamId); }
From source file:org.xingjitong.ContactFragment.java
private void displayContact(LayoutInflater inflater, View view) { AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream(getActivity().getContentResolver(), contact.getID());/* w ww . j a v a 2 s .c o m*/ contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); } else { contactPicture.setImageResource(R.drawable.unknown_small); } TextView contactName = (TextView) view.findViewById(R.id.contactName); contactName.setText(contact.getName()); contactName.setTextColor(Color.BLACK); View view2 = inflater.inflate(R.layout.edit_contact, null); TableLayout controls = (TableLayout) view2.findViewById(R.id.controls); if (controls.getChildCount() > 0 && controls != null) { controls.removeAllViews(); } for (String numberOrAddress : contact.getNumerosOrAddresses()) { //yyppdialog View v = inflater.inflate(R.layout.contact_control_row, null); String displayednumberOrAddress = numberOrAddress; if (numberOrAddress.startsWith("sip:")) { displayednumberOrAddress = displayednumberOrAddress.substring(4); } TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress); tv.setText(displayednumberOrAddress); tv.setSelected(true); if (!displayChatAddressOnly) { //yyppcontact //yyppdialog v.findViewById(R.id.dial).setOnClickListener(dialListener); v.findViewById(R.id.dial).setTag(displayednumberOrAddress); } else { v.findViewById(R.id.dial).setVisibility(View.GONE); } v.findViewById(R.id.chat).setOnClickListener(chatListener); if (LinphoneUtils.isSipAddress(numberOrAddress)) { v.findViewById(R.id.chat).setTag(numberOrAddress); } else { LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig(); if (lpc != null) { if (!numberOrAddress.startsWith("sip:")) { numberOrAddress = "sip:" + numberOrAddress; } v.findViewById(R.id.chat).setTag(numberOrAddress + "@" + lpc.getDomain()); } } final String finalNumberOrAddress = numberOrAddress; ImageView friend = (ImageView) v.findViewById(R.id.addFriend); if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) { friend.setVisibility(View.VISIBLE); boolean isAlreadyAFriend = LinphoneManager.getLc() .findFriendByAddress(finalNumberOrAddress) != null; if (!isAlreadyAFriend) { friend.setImageResource(R.drawable.friend_add); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().newFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } else { friend.setImageResource(R.drawable.friend_remove); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().removeFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } } if (getResources().getBoolean(R.bool.disable_chat)) { v.findViewById(R.id.chat).setVisibility(View.GONE); } controls.addView(v); } }
From source file:com.njlabs.amrita.aid.aums.AumsActivity.java
private void loadPhoto() { aums.getPhotoFile(new FileResponse() { @Override// w w w. ja v a2 s . com public void onSuccess(File file) { findViewById(R.id.student_profile_pic_progress).setVisibility(View.GONE); ImageView myImage = (ImageView) findViewById(R.id.student_profile_pic); myImage.setVisibility(View.VISIBLE); Picasso.with(baseContext).load(file).error(R.drawable.user).into(myImage); } @Override public void onFailure(Throwable throwable) { Ln.e(throwable); findViewById(R.id.student_profile_pic_progress).setVisibility(View.GONE); ImageView myImage = (ImageView) findViewById(R.id.student_profile_pic); myImage.setVisibility(View.VISIBLE); myImage.setImageResource(R.drawable.user); } }); }
From source file:com.viewpagerindicator.TabTextPageIndicator.java
private void addTab(int index, CharSequence text, int layoutID, boolean showLine) { final TabView tabView = new TabView(getContext()); tabView.mIndex = index;// w w w . j av a2 s.c om tabView.setOnClickListener(mTabClickListener); View view = LayoutInflater.from(getContext()).inflate(R.layout.lib_layout_viewpagerindicator_pager_title, null); TextView tv = (TextView) view.findViewById(R.id.lib_id_viewpagerindicator_pager_title); tv.setText(text); // // tv.getPaint().setFakeBoldText(true); setTextColor(tv); ImageView newsIv = (ImageView) view.findViewById(R.id.lib_id_viewpagerindicator_pager_news); if (getNewsCirle(index)) { newsIv.setVisibility(View.VISIBLE); } ImageView line = (ImageView) view.findViewById(R.id.lib_id_viewpagerindicator_pager_line); if (!showLine) { line.setVisibility(View.INVISIBLE); } tabView.addView(view); tabView.setGravity(Gravity.CENTER); if (isLayoutWeight) { mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, WRAP_CONTENT, 1)); } else { mTabLayout.addView(tabView, new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)); } }
From source file:com.brq.wallet.activity.main.AddressFragment.java
private void updateUi() { if (!isAdded()) { return;/*w ww . j a v a 2 s . c om*/ } if (_mbwManager.getSelectedAccount().isArchived()) { return; } // Update QR code QrImageView qrButton = (QrImageView) Preconditions.checkNotNull(_root.findViewById(R.id.ivQR)); Optional<Address> receivingAddress = getAddress(); // Update address if (receivingAddress.isPresent()) { // Set address qrButton.setVisibility(View.VISIBLE); qrButton.setQrCode(BitcoinUriWithAddress.fromAddress(receivingAddress.get()).toString()); String[] addressStrings = Utils.stringChopper(receivingAddress.get().toString(), 12); ((TextView) _root.findViewById(R.id.tvAddress1)).setText(addressStrings[0]); ((TextView) _root.findViewById(R.id.tvAddress2)).setText(addressStrings[1]); ((TextView) _root.findViewById(R.id.tvAddress3)).setText(addressStrings[2]); if (_showBip44Path && receivingAddress.get() instanceof HdDerivedAddress) { HdDerivedAddress hdAdr = (HdDerivedAddress) receivingAddress.get(); ((TextView) _root.findViewById(R.id.tvAddressPath)).setText(hdAdr.getBip32Path().toString()); } else { ((TextView) _root.findViewById(R.id.tvAddressPath)).setText(""); } } else { // No address available qrButton.setVisibility(View.INVISIBLE); ((TextView) _root.findViewById(R.id.tvAddress1)).setText(""); ((TextView) _root.findViewById(R.id.tvAddress2)).setText(""); ((TextView) _root.findViewById(R.id.tvAddress3)).setText(""); ((TextView) _root.findViewById(R.id.tvAddressPath)).setText(""); } // Show name of bitcoin address according to address book TextView tvAddressTitle = (TextView) _root.findViewById(R.id.tvAddressLabel); ImageView ivAccountType = (ImageView) _root.findViewById(R.id.ivAccountType); String name = _mbwManager.getMetadataStorage().getLabelByAccount(_mbwManager.getSelectedAccount().getId()); if (name.length() == 0) { tvAddressTitle.setVisibility(View.GONE); ivAccountType.setVisibility(View.GONE); } else { tvAddressTitle.setVisibility(View.VISIBLE); tvAddressTitle.setText(name); // show account type icon next to the name Drawable drawableForAccount = Utils.getDrawableForAccount(_mbwManager.getSelectedAccount(), true, getResources()); if (drawableForAccount == null) { ivAccountType.setVisibility(View.GONE); } else { ivAccountType.setImageDrawable(drawableForAccount); ivAccountType.setVisibility(View.VISIBLE); } } }