Example usage for android.widget ImageView setVisibility

List of usage examples for android.widget ImageView setVisibility

Introduction

In this page you can find the example usage for android.widget ImageView setVisibility.

Prototype

@RemotableViewMethod
    @Override
    public void setVisibility(int visibility) 

Source Link

Usage

From source file:com.example.alexs.tourguide.dcAdapter.java

/**
 * Provides a view for an AdapterView (ListView, GridView, etc.)
 *
 * @param position The position in the list of data that should be displayed in the
 *                 list item view.//from  w w  w  . j  a va2 s.  c  o  m
 * @param convertView The recycled view to populate.
 * @param parent The parent ViewGroup that is used for inflation.
 * @return The View for the position in the AdapterView.
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Check if the 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);
    }

    // Find the TextView for the list text
    LinearLayout backColorView = (LinearLayout) listItemView.findViewById(R.id.listText);
    backColorView.setBackgroundColor(ContextCompat.getColor(getContext(), mColorID));

    // Get the {@link dcAttractions} object located at this position in the list
    dcAttractions currentAttraction = getItem(position);

    // Find the TextView in the list_item.xml layout with the ID version_name
    TextView nameTextView = (TextView) listItemView.findViewById(R.id.attraction_name);
    // Get the version name from the current dcAttractions object and
    // set this text on the name TextView
    nameTextView.setText(currentAttraction.getAttractionName());

    // Find the TextView in the list_item.xml layout with the ID version_number
    TextView summaryTextView = (TextView) listItemView.findViewById(R.id.attraction_summary);
    // Get the version number from the current dcAttractions object and
    // set this text on the number TextView
    summaryTextView.setText(currentAttraction.getAttractionSummary());

    // Find the TextView in the list_item.xml layout with the ID version_number
    TextView addressTextView = (TextView) listItemView.findViewById(R.id.attraction_address);
    // Get the version number from the current dcAttractions object and
    // set this text on the number TextView
    addressTextView.setText(currentAttraction.getAttractionAddress());

    // Find the ImageView in the list_item.xml layout with the ID list_item_icon
    ImageView iconView = (ImageView) listItemView.findViewById(R.id.list_item_icon);
    // Get the image resource ID from the current dcAttractions object and
    // set the image to iconView
    if (currentAttraction.hasImage()) {
        iconView.setImageResource(currentAttraction.getImageResourceId());
    } else {
        iconView.setVisibility(View.GONE);
    }

    // Return the whole list item layout (containing 2 TextViews and an ImageView)
    // so that it can be shown in the ListView
    return listItemView;
}

From source file:ru.orangesoftware.financisto.activity.CategorySelector.java

private void showHideMinusBtn(boolean show) {
    ImageView minusBtn = (ImageView) categoryText.getTag(R.id.bMinus);
    if (minusBtn != null)
        minusBtn.setVisibility(show ? View.VISIBLE : View.GONE);
}

From source file:de.questmaster.fatremote.fragments.RemoteFragment.java

private void showKeyboard() {
    // show edittext and give it focus
    ImageView button = (ImageView) c.findViewById(R.id.textButton);
    EditText text = (EditText) c.findViewById(R.id.enterText);
    button.setVisibility(View.GONE);
    text.setVisibility(View.VISIBLE);
    text.requestFocus();//from   www.j  ava 2  s . co m

    // show keyboard
    InputMethodManager mgr = (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.toggleSoftInput(0, 0);
}

From source file:com.example.android.saddacampus.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 ava 2  s  . 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.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.gudong.appkit.ui.fragment.ColorChooseDialog.java

private View getColorItemView(final Context context, int position, boolean isSelect) {
    int color = mColors[position];
    int widthImageCheckView = Utils.convertDensityPix(context, 24);
    int widthColorView = Utils.convertDensityPix(context, 56);
    int widthMargin = Utils.convertDensityPix(context, 4);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.ic_check);

    FrameLayout.LayoutParams ivParams = new FrameLayout.LayoutParams(widthImageCheckView, widthImageCheckView);
    ivParams.gravity = Gravity.CENTER;/*from   www.  ja va  2  s . co  m*/
    imageView.setLayoutParams(ivParams);
    imageView.setVisibility(isSelect ? View.VISIBLE : View.INVISIBLE);

    FrameLayout frameLayout = new FrameLayout(context);
    GridLayout.LayoutParams params = new GridLayout.LayoutParams(
            new FrameLayout.LayoutParams(widthColorView, widthColorView));
    params.setGravity(Gravity.CENTER);
    params.setMargins(widthMargin, widthMargin, widthMargin, widthMargin);
    frameLayout.setLayoutParams(params);

    setBackgroundSelector(frameLayout, color);

    frameLayout.addView(imageView);
    frameLayout.setOnClickListener(this);
    frameLayout.setTag(position);
    return frameLayout;
}

From source file:cn.wander.Utils.views.pageindicator.TabPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    RelativeLayout tablayout = (RelativeLayout) View.inflate(getContext(), R.layout.tab_item_layout, null);

    final TextView tabView = (TextView) tablayout.findViewById(R.id.tab_item_title);
    tabView.setTag(index);/*from w  ww.ja v  a2s . c  o  m*/
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 19);
    tabView.setText(text);
    tabView.setTextColor(getResources().getColor(R.color.kw_common_cl_white));
    if (iconResId != 0) {
        //             tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
        ImageView iconView = (ImageView) tablayout.findViewById(R.id.tab_item_icon);
        iconView.setImageResource(iconResId);
        iconView.setVisibility(View.VISIBLE);
    }

    mTabLayout.addView(tablayout, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
}

From source file:org.linphone.ContactFragment.java

@SuppressLint("InflateParams")
private void displayContact(LayoutInflater inflater, View view) {
    AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);
    if (contact.getPhotoUri() != null) {
        InputStream input = Compatibility.getContactPictureInputStream(
                LinphoneActivity.instance().getContentResolver(), contact.getID());
        contactPicture.setImageBitmap(BitmapFactory.decodeStream(input));
    } else {/*from  w  w  w.j  a v a2 s.co  m*/
        contactPicture.setImageResource(R.drawable.unknown_small);
    }

    TextView contactName = (TextView) view.findViewById(R.id.contactName);
    contactName.setText(contact.getName());

    TableLayout controls = (TableLayout) view.findViewById(R.id.controls);
    controls.removeAllViews();
    for (String numberOrAddress : contact.getNumbersOrAddresses()) {
        View v = inflater.inflate(R.layout.contact_control_row, null);

        String displayednumberOrAddress = numberOrAddress;
        if (numberOrAddress.startsWith("sip:")) {
            displayednumberOrAddress = displayednumberOrAddress.replace("sip:", "");
        }

        TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress);
        tv.setText(displayednumberOrAddress);
        tv.setSelected(true);

        if (!displayChatAddressOnly) {
            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.start_chat).setOnClickListener(chatListener);
        LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig();
        if (lpc != null) {
            displayednumberOrAddress = lpc.normalizePhoneNumber(displayednumberOrAddress);
            if (!displayednumberOrAddress.startsWith("sip:")) {
                numberOrAddress = "sip:" + displayednumberOrAddress;
            }

            String tag = numberOrAddress;
            if (!numberOrAddress.contains("@")) {
                tag = numberOrAddress + "@" + lpc.getDomain();
            }
            v.findViewById(R.id.start_chat).setTag(tag);
        } else {
            v.findViewById(R.id.start_chat).setTag(numberOrAddress);
        }

        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 (ContactsManager.getInstance().createNewFriend(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 (ContactsManager.getInstance().removeFriend(finalNumberOrAddress)) {
                            displayContact(ContactFragment.this.inflater, ContactFragment.this.view);
                        }
                    }
                });
            }
        }

        if (getResources().getBoolean(R.bool.disable_chat)) {
            v.findViewById(R.id.start_chat).setVisibility(View.GONE);
        }

        controls.addView(v);
    }
}

From source file:com.bonsai.btcreceive.ReceiveFragment.java

public void hideAddress() {
    TextView addrtv = (TextView) getActivity().findViewById(R.id.receive_addr);
    addrtv.setVisibility(View.GONE);

    ImageView iv = (ImageView) getActivity().findViewById(R.id.receive_qr_view);
    iv.setVisibility(View.GONE);

    // Clear the HDAddress associated with this address.
    mHDAddress = null;//w ww  . j a  v  a 2  s . c  o  m
    mTransitioned = false;

    mFiatAmountEditText.setFocusable(true);
    mFiatAmountEditText.setFocusableInTouchMode(true);
    mBTCAmountEditText.setFocusable(true);
    mBTCAmountEditText.setFocusableInTouchMode(true);
}

From source file:fm.smart.r1.ItemActivity.java

static void setSound(ImageView sound_icon, final String sound_url, final Context context, final int type_id,
        final String artifact_id, final String to_record) {
    if (!TextUtils.isEmpty(sound_url)) {
        OnClickListener sound_listener = new OnClickListener() {
            public void onClick(View v) {// TODO removed temporarily
                MediaUtility.playSound(sound_url, ItemListActivity.mMediaPlayer, context);
            }// w w  w . jav a  2 s.c o m
        };
        sound_icon.setOnClickListener(sound_listener);
        sound_icon
                .setImageBitmap(BitmapFactory.decodeResource(context.getResources(), R.drawable.active_sound));
    } else {
        if (type_id == R.id.response_sound || type_id == R.id.translation_sound) {
            sound_icon.setVisibility(View.INVISIBLE);
        } else {
            sound_icon.setImageBitmap(
                    BitmapFactory.decodeResource(context.getResources(), R.drawable.inactive_sound_add));

            OnClickListener listener = new OnClickListener() {
                public void onClick(View v) {
                    // TODO removed temporarily
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setClassName(context, CreateSoundActivity.class.getName());
                    AndroidUtils.putExtra(intent, "item_id", (String) item.getId());
                    AndroidUtils.putExtra(intent, "to_record", to_record);
                    AndroidUtils.putExtra(intent, "id", artifact_id);
                    AndroidUtils.putExtra(intent, "sound_type", Integer.toString(type_id));
                    context.startActivity(intent);

                }
            };
            sound_icon.setOnClickListener(listener);
        }
    }
}

From source file:com.example.android.gft.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  a v a2 s  .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.getMiwokTranslationId());

    // 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.getDefaultTranslationId());

    // 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;
}