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.jacob_ke.myapplication.Fragment_Content.java

public void updateContentView(int position) {
    Log.v(TAG, "updateArticleView");
    TextView article = (TextView) getActivity().findViewById(R.id.article);
    article.setText(Fragment_Array.Articles[position]);
    Button button = (Button) getActivity().findViewById(R.id.demo);
    button.setOnClickListener(new View.OnClickListener() {
        @Override/*  w  w w .j  a  v a 2  s.c o  m*/
        public void onClick(View view) {
            Intent intent = new Intent(getActivity(), DisplayMessageActivity_1.class);
            startActivity(intent);
        }
    });
    ImageView img = (ImageView) getActivity().findViewById(R.id.img);
    img.setImageResource(R.drawable.unweb);
    if (position == 0) {

        button.setVisibility(View.VISIBLE);
        img.setVisibility(View.INVISIBLE);
    } else {
        button.setVisibility(View.INVISIBLE);
        img.setVisibility(View.VISIBLE);
    }
    mCurrentPosition = position;
}

From source file:com.mobicage.rogerthat.FriendDetailOrInviteActivity.java

private void updateView() {
    final ImageView image = (ImageView) findViewById(R.id.friend_avatar);

    if (mFriend == null) {
        image.setVisibility(View.INVISIBLE);
        return;/*from  w  w  w  . j  a  v a 2s .c om*/
    }
    image.setVisibility(View.VISIBLE);
    final TextView nameView = (TextView) findViewById(R.id.friend_name);

    if (mFriend.avatar == null) {
        image.setImageBitmap(mFriendsPlugin.getMissingFriendAvatarBitmap());
    } else {
        final Bitmap avatarBitmap = BitmapFactory.decodeByteArray(mFriend.avatar, 0, mFriend.avatar.length);
        image.setImageBitmap(ImageHelper.getRoundedCornerAvatar(avatarBitmap));
    }

    setTitle(mFriend.getDisplayName());
    nameView.setText(mFriend.getDisplayName());
    nameView.setTextColor(ContextCompat.getColor(this, android.R.color.primary_text_light));

    final LinearLayout profileDataContainer = (LinearLayout) findViewById(R.id.profile_data);
    if (AppConstants.PROFILE_DATA_FIELDS.length > 0) {
        profileDataContainer.removeAllViews();
        profileDataContainer.setVisibility(View.VISIBLE);
        Map<String, String> profileData = mFriend.getProfileDataDict();
        for (String k : AppConstants.PROFILE_DATA_FIELDS) {
            final LinearLayout ll = (LinearLayout) View.inflate(this, R.layout.profile_data_detail, null);
            final TextView tvKey = (TextView) ll.findViewById(R.id.profile_data_detail_key);
            final TextView tvVal = (TextView) ll.findViewById(R.id.profile_data_detail_value);

            String v = profileData == null ? null : profileData.get(k);
            if (v == null) {
                v = getString(R.string.unknown);
            }
            tvKey.setText(k);
            tvKey.setTextColor(LookAndFeelConstants.getPrimaryColor(this));
            tvVal.setText(v);

            profileDataContainer.addView(ll);
        }
    } else {
        profileDataContainer.setVisibility(View.GONE);
    }
}

From source file:org.gluu.super_gluu.app.fragments.SettingsFragment.SettingsList.SettingsListFragmentAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;//w w  w .  j a v a  2s .  co  m

    if (view == null) {
        LayoutInflater inflater = mInflater;
        view = inflater.inflate(R.layout.fragment_setting_list, null);
    }
    Map<String, Integer> item = list.get(position);
    Map.Entry<String, Integer> entry = item.entrySet().iterator().next();
    view.setTag(entry);
    TextView settingName = (TextView) view.findViewById(R.id.settings_name);

    if (settingName != null) {
        settingName.setText(entry.getKey());
        settingName.setTypeface(face);
    }
    ImageView settingArrow = (ImageView) view.findViewById(R.id.settingArrow);
    TextView info = (TextView) view.findViewById(R.id.textInfo);
    settingArrow.setVisibility(View.VISIBLE);
    settingArrow.setVisibility(View.GONE);
    if (entry.getValue() == FragmentType.SETTINGS_FRAGMENT_TYPE.VERSION_FRAGMENT.ordinal()) {
        int versionCode = BuildConfig.VERSION_CODE;
        String versionName = BuildConfig.VERSION_NAME;
        info.setText(versionName + " - " + String.valueOf(versionCode));
        view.setBackgroundColor(Color.WHITE);
        info.setVisibility(View.VISIBLE);
        info.setTypeface(face);
    } else if (entry.getValue() != FragmentType.SETTINGS_FRAGMENT_TYPE.EMPTY_FRAGMENT.ordinal()) {
        info.setVisibility(View.GONE);
        settingArrow.setVisibility(View.VISIBLE);
        view.setBackgroundColor(Color.WHITE);
    } else {
        view.setBackgroundColor(Color.parseColor("#efeff4"));
    }

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Map.Entry<String, Integer> entry = (Map.Entry<String, Integer>) v.getTag();
            if (mListener != null
                    && entry.getValue() == FragmentType.SETTINGS_FRAGMENT_TYPE.PIN_CODE_FRAGMENT.ordinal()) {
                mListener.onSettingsList(new SettingsPinCode());
            } else if (mListener != null
                    && entry.getValue() == FragmentType.SETTINGS_FRAGMENT_TYPE.FINGERPRINT_FRAGMENT.ordinal()) {
                mListener.onSettingsList(createSettingsFragment("FingerprintSettings"));
            } else if (mListener != null
                    && entry.getValue() == FragmentType.SETTINGS_FRAGMENT_TYPE.SSL_FRAGMENT.ordinal()) {
                mListener.onSettingsList(createSettingsFragment("SSLConnectionSettings"));
            } else if (entry.getValue() == FragmentType.SETTINGS_FRAGMENT_TYPE.USER_GUIDE_FRAGMENT.ordinal()) {
                Uri uri = Uri.parse("https://gluu.org/docs/supergluu/3.0.0/user-guide/");
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                activity.startActivity(intent);
            } else if (entry.getValue() == FragmentType.SETTINGS_FRAGMENT_TYPE.PRIVACY_POLICY_FRAGMENT
                    .ordinal()) {
                LicenseFragment licenseFragment = new LicenseFragment();
                licenseFragment.setForFirstLoading(false);
                mListener.onSettingsList(licenseFragment);
            } else if (entry.getValue() == FragmentType.SETTINGS_FRAGMENT_TYPE.AD_FREE_FRAGMENT.ordinal()) {
                PurchaseFragment purchaseFragment = new PurchaseFragment();
                mListener.onSettingsList(purchaseFragment);
            }
        }
    });

    return view;
}

From source file:org.sufficientlysecure.keychain.ui.adapter.SubkeysAddedAdapter.java

public View getView(final int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        // Not recycled, inflate a new view
        convertView = mInflater.inflate(R.layout.view_key_adv_subkey_item, parent, false);
        final ViewHolder holder = new ViewHolder();
        holder.vKeyId = (TextView) convertView.findViewById(R.id.subkey_item_key_id);
        holder.vKeyDetails = (TextView) convertView.findViewById(R.id.subkey_item_details);
        holder.vKeyExpiry = (TextView) convertView.findViewById(R.id.subkey_item_expiry);
        holder.vCertifyIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_certify);
        holder.vSignIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_sign);
        holder.vEncryptIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_encrypt);
        holder.vAuthenticateIcon = (ImageView) convertView.findViewById(R.id.subkey_item_ic_authenticate);

        holder.vDelete = (ImageButton) convertView.findViewById(R.id.subkey_item_delete_button);
        holder.vDelete.setVisibility(View.VISIBLE); // always visible

        // not used:
        ImageView vEdit = (ImageView) convertView.findViewById(R.id.subkey_item_edit_image);
        vEdit.setVisibility(View.GONE);
        ImageView vStatus = (ImageView) convertView.findViewById(R.id.subkey_item_status);
        vStatus.setVisibility(View.GONE);

        convertView.setTag(holder);//from   w  ww . j  av  a  2  s .co  m
    }

    final ViewHolder holder = (ViewHolder) convertView.getTag();

    // save reference to model item
    holder.mModel = getItem(position);

    String algorithmStr = KeyFormattingUtils.getAlgorithmInfo(mActivity, holder.mModel.mAlgorithm,
            holder.mModel.mKeySize, holder.mModel.mCurve);

    boolean isMasterKey = mNewKeyring && position == 0;
    if (isMasterKey) {
        holder.vKeyId.setTypeface(null, Typeface.BOLD);
        holder.vDelete.setImageResource(R.drawable.ic_change_grey_24dp);
        holder.vDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // swapping out the old master key with newly set master key
                AddSubkeyDialogFragment addSubkeyDialogFragment = AddSubkeyDialogFragment.newInstance(true);
                addSubkeyDialogFragment.setOnAlgorithmSelectedListener(
                        new AddSubkeyDialogFragment.OnAlgorithmSelectedListener() {
                            @Override
                            public void onAlgorithmSelected(SaveKeyringParcel.SubkeyAdd newSubkey) {
                                // calculate manually as the provided position variable
                                // is not always accurate
                                int pos = SubkeysAddedAdapter.this.getPosition(holder.mModel);
                                SubkeysAddedAdapter.this.remove(holder.mModel);
                                SubkeysAddedAdapter.this.insert(newSubkey, pos);
                            }
                        });
                addSubkeyDialogFragment.show(((FragmentActivity) mActivity).getSupportFragmentManager(),
                        "addSubkeyDialog");
            }
        });
    } else {
        holder.vKeyId.setTypeface(null, Typeface.NORMAL);
        holder.vDelete.setImageResource(R.drawable.ic_close_grey_24dp);
        holder.vDelete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // remove reference model item from adapter (data and notify about change)
                SubkeysAddedAdapter.this.remove(holder.mModel);
            }
        });
    }

    holder.vKeyId.setText(R.string.edit_key_new_subkey);
    holder.vKeyDetails.setText(algorithmStr);

    if (holder.mModel.mExpiry != 0L) {
        Date expiryDate = new Date(holder.mModel.mExpiry * 1000);
        Calendar expiryCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        expiryCal.setTime(expiryDate);
        // convert from UTC to time zone of device
        expiryCal.setTimeZone(TimeZone.getDefault());

        holder.vKeyExpiry.setText(getContext().getString(R.string.label_expiry) + ": "
                + DateFormat.getDateFormat(getContext()).format(expiryCal.getTime()));
    } else {
        holder.vKeyExpiry.setText(
                getContext().getString(R.string.label_expiry) + ": " + getContext().getString(R.string.none));
    }

    int flags = holder.mModel.mFlags;
    if ((flags & KeyFlags.CERTIFY_OTHER) > 0) {
        holder.vCertifyIcon.setVisibility(View.VISIBLE);
    } else {
        holder.vCertifyIcon.setVisibility(View.GONE);
    }
    if ((flags & KeyFlags.SIGN_DATA) > 0) {
        holder.vSignIcon.setVisibility(View.VISIBLE);
    } else {
        holder.vSignIcon.setVisibility(View.GONE);
    }
    if (((flags & KeyFlags.ENCRYPT_COMMS) > 0) || ((flags & KeyFlags.ENCRYPT_STORAGE) > 0)) {
        holder.vEncryptIcon.setVisibility(View.VISIBLE);
    } else {
        holder.vEncryptIcon.setVisibility(View.GONE);
    }
    if ((flags & KeyFlags.AUTHENTICATION) > 0) {
        holder.vAuthenticateIcon.setVisibility(View.VISIBLE);
    } else {
        holder.vAuthenticateIcon.setVisibility(View.GONE);
    }

    return convertView;
}

From source file:com.gammalabs.wifianalyzer.wifi.AccessPointDetail.java

private void setViewExtra(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail) {
    ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage);
    WiFiAdditional wiFiAdditional = wiFiDetail.getWiFiAdditional();
    if (wiFiAdditional.isConfiguredNetwork()) {
        configuredImage.setVisibility(View.VISIBLE);
        configuredImage.setColorFilter(ContextCompat.getColor(context, R.color.connected));
    } else {//www.j a v a2  s.c  o  m
        configuredImage.setVisibility(View.GONE);
    }

    WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal();
    Strength strength = wiFiSignal.getStrength();
    ImageView imageView = (ImageView) view.findViewById(R.id.levelImage);
    imageView.setImageResource(strength.imageResource());
    imageView.setColorFilter(ContextCompat.getColor(context, strength.colorResource()));

    ((TextView) view.findViewById(R.id.channel_frequency_range))
            .setText(wiFiSignal.getFrequencyStart() + " - " + wiFiSignal.getFrequencyEnd());
    ((TextView) view.findViewById(R.id.width))
            .setText("(" + wiFiSignal.getWiFiWidth().getFrequencyWidth() + WiFiSignal.FREQUENCY_UNITS + ")");
    ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities());
}

From source file:com.linkedin.android.eventsapp.ProfileActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);//from  w w w  . java 2  s.c om
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            currentActivity.finish();
        }
    });

    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
        String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
        APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() {
            @Override
            public void onApiSuccess(ApiResponse apiResponse) {
                try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName = location != null && location.has("name") ? location.getString("name")
                            : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                        new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                        attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                } catch (JSONException e) {

                }

            }

            @Override
            public void onApiError(LIApiError apiError) {

            }
        });

        ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
        View viewOnLI = viewOnLIStub.inflate();
        Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
        viewOnLIButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(),
                        new DeepLinkListener() {
                            @Override
                            public void onDeepLinkSuccess() {

                            }

                            @Override
                            public void onDeepLinkError(LIDeepLinkError error) {

                            }
                        });
            }
        });
    } else {
        attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
}

From source file:com.chocopepper.chococam.activity.friends.manage.FriendsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.friends);//from   ww w  . j a  v a 2  s  .  c  om

    sharedPref = getSharedPreferences(Constants.SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
    selectedPagerIndex = sharedPref.getInt(PAGER_INDEX, VIEW_FRIENDLIST);

    ImageView btnCreatechat = (ImageView) findViewById(R.id.btnCreateChat);
    btnCreatechat.setVisibility(View.GONE);

    TextView txt_title = (TextView) findViewById(R.id.title);
    txt_title.setText(R.string.friends_tab_sub_suggestion);

    List<Fragment> fragments = new Vector<Fragment>();

    final Fragment frFreindsList = Fragment.instantiate(this, FriendsList.class.getName());

    Intent i = getIntent();
    long target_user_id = i.getLongExtra(Constants.TARGET_USER_ID,
            UserService.getDefaultUserId(FriendsActivity.this));
    Bundle args = new Bundle();
    args.putLong(Constants.TARGET_USER_ID, target_user_id);

    selectedPagerIndex = i.getIntExtra(PAGER_INDEX, selectedPagerIndex);

    frFreindsList.setArguments(args);
    fragments.add(frFreindsList);
    //fragments.add(Fragment.instantiate(this, FriendsList.class.getName()));

    fragments.add(Fragment.instantiate(this, RecommendedFriends.class.getName()));
    fragments.add(Fragment.instantiate(this, ReceivedRequests.class.getName()));

    btnEdit = (RelativeLayout) findViewById(R.id.btnEdit);
    btnEdit.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // ? ? ?   ?
            ((FriendsList) frFreindsList).switchEditMode();
        }
    });

    mAdapter = new FriendsAdapter(getSupportFragmentManager(), fragments);
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_current_friends));
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_suggestion));
    //mAdapter.addTitle(this.getString(R.string.friends_tab_sub_invitation));
    mAdapter.addTitle(this.getString(R.string.friends_tab_sub_received_invitation));

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAdapter);

    //  .
    mViewPager.setCurrentItem(selectedPagerIndex);
    // 2012-05-23 brucewang
    if (selectedPagerIndex == 0) {
        btnEdit.setVisibility(View.VISIBLE);
    }

    //mIndicator = (TitlePageIndicator)findViewById(R.id.indicator);
    //        mIndicator = (ViewPagerIndicator)findViewById(R.id.indicator);
    //      mIndicator.addPageChangeListener(this);
    //        mViewPager.setOnPageChangeListener(mIndicator);

    indicator = (TitlePageIndicator) findViewById(R.id.indicator);
    indicator.setFooterIndicatorStyle(IndicatorStyle.None);
    indicator.setViewPager(mViewPager, selectedPagerIndex);
    indicator.setOnPageChangeListener(this);
    mViewPager.setOnPageChangeListener(indicator);

}

From source file:com.frostwire.android.gui.activities.internal.NavigationMenu.java

private NavigationView initNavigationView(final MainActivity activity) {
    NavigationView resultNavView = navView;
    if (navView == null) {
        resultNavView = activity.findViewById(R.id.activity_main_nav_view);
        resultNavView.setNavigationItemSelectedListener(menuItem -> {
            onMenuItemSelected(menuItem);
            return true;
        });//from  w ww.  j a  v  a  2 s  .  com
        View navViewHeader = resultNavView.getHeaderView(0);
        // Logo
        ImageView navLogo = navViewHeader.findViewById(R.id.nav_view_header_main_app_logo);
        navLogo.setOnClickListener(v -> UIUtils.openURL(v.getContext(), Constants.FROSTWIRE_GIVE_URL));

        // Prep title and version
        TextView title = navViewHeader.findViewById(R.id.nav_view_header_main_title);
        TextView version = navViewHeader.findViewById(R.id.nav_view_header_main_version);
        String basicOrPlus = (String) activity
                .getText(Constants.IS_GOOGLE_PLAY_DISTRIBUTION ? R.string.basic : R.string.plus);
        boolean isDevelopment = Constants.IS_BASIC_AND_DEBUG;
        if (isDevelopment) {
            basicOrPlus = "Developer";
        }
        title.setText("FrostWire " + basicOrPlus);
        version.setText(" v" + Constants.FROSTWIRE_VERSION_STRING);
        TextView build = navViewHeader.findViewById(R.id.nav_view_header_main_build);
        build.setText(activity.getText(R.string.build) + " " + BuildConfig.VERSION_CODE);
        View.OnClickListener aboutActivityLauncher = v -> {
            Intent intent = new Intent(v.getContext(), AboutActivity.class);
            v.getContext().startActivity(intent);
        };
        title.setOnClickListener(aboutActivityLauncher);
        version.setOnClickListener(aboutActivityLauncher);
        build.setOnClickListener(aboutActivityLauncher);

        // Prep update button
        ImageView updateButton = navViewHeader.findViewById(R.id.nav_view_header_main_update);
        updateButton.setVisibility(View.GONE);
        updateButton.setOnClickListener(v -> onUpdateButtonClicked(activity));
    }
    return resultNavView;
}

From source file:com.idt.ontomedia.geoconsum.BaseActivity.java

private Dialog setDialogWithCheck(int _id) {
    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.dialog_with_check);

    TextView textViewInfo = (TextView) dialog.findViewById(R.id.text_layout);
    CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.checkBox1);

    switch (_id) {
    case DIALOG_ABOUT_ID: {
        dialog.setTitle(getResources().getString(R.string.dialog_title_about) + " "
                + getResources().getString(R.string.app_name));
        dialog.setCancelable(true);/*from   w ww .  j  a  v a2 s  . com*/

        checkBox.setVisibility(View.GONE);

        ImageView imageViewBanner = (ImageView) dialog.findViewById(R.id.imageViewBanner);
        imageViewBanner.setImageDrawable(getResources().getDrawable(R.drawable.logo_idt));
        imageViewBanner.setVisibility(View.VISIBLE);

        textViewInfo.setText(R.string.dialog_text_about);
    }
    case DIALOG_WARNING_ID: {
        dialog.setTitle(getResources().getString(R.string.dialog_title_warning));
        dialog.setCancelable(false);

        textViewInfo.setText(R.string.dialog_text_warning);

        checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton _buttonView, boolean _isChecked) {
                SharedPreferences sharedPreferences = PreferenceManager
                        .getDefaultSharedPreferences(getBaseContext());
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putBoolean(DialogPreferenceActivity.PREF_DIALOG_CHECK, _isChecked);
                editor.commit();
            }
        });
    }
    }

    Button acceptButton = (Button) dialog.findViewById(R.id.button1);
    acceptButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.cancel();
        }

    });

    return dialog;
}

From source file:org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {
    TextView vName = (TextView) view.findViewById(R.id.user_id_item_name);
    TextView vAddress = (TextView) view.findViewById(R.id.user_id_item_address);
    TextView vComment = (TextView) view.findViewById(R.id.user_id_item_comment);
    ImageView vVerified = (ImageView) view.findViewById(R.id.user_id_item_certified);
    ViewAnimator vVerifiedLayout = (ViewAnimator) view.findViewById(R.id.user_id_icon_animator);

    ImageView vDeleteButton = (ImageView) view.findViewById(R.id.user_id_item_delete_button);
    vDeleteButton.setVisibility(View.GONE); // not used

    String userId = cursor.getString(INDEX_USER_ID);
    OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(userId);
    if (splitUserId.name != null) {
        vName.setText(splitUserId.name);
    } else {/*from   w  w  w  .  j  a  v a2 s  .  c  o  m*/
        vName.setText(R.string.user_id_no_name);
    }
    if (splitUserId.email != null) {
        vAddress.setText(splitUserId.email);
        vAddress.setVisibility(View.VISIBLE);
    } else {
        vAddress.setVisibility(View.GONE);
    }
    if (splitUserId.comment != null) {
        vComment.setText(splitUserId.comment);
        vComment.setVisibility(View.VISIBLE);
    } else {
        vComment.setVisibility(View.GONE);
    }

    boolean isPrimary = cursor.getInt(INDEX_IS_PRIMARY) != 0;
    boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;

    // for edit key
    if (mSaveKeyringParcel != null) {
        boolean changeAnyPrimaryUserId = (mSaveKeyringParcel.mChangePrimaryUserId != null);
        boolean changeThisPrimaryUserId = (mSaveKeyringParcel.mChangePrimaryUserId != null
                && mSaveKeyringParcel.mChangePrimaryUserId.equals(userId));
        boolean revokeThisUserId = (mSaveKeyringParcel.mRevokeUserIds.contains(userId));

        // only if primary user id will be changed
        // (this is not triggered if the user id is currently the primary one)
        if (changeAnyPrimaryUserId) {
            // change _all_ primary user ids and set new one to true
            isPrimary = changeThisPrimaryUserId;
        }

        if (revokeThisUserId) {
            if (!isRevoked) {
                isRevoked = true;
            }
        }

        vVerifiedLayout.setDisplayedChild(2);
    } else {
        vVerifiedLayout.setDisplayedChild(mShowStatusImages ? 1 : 0);
    }

    if (isRevoked) {
        // set revocation icon (can this even be primary?)
        KeyFormattingUtils.setStatusImage(mContext, vVerified, null, State.REVOKED, R.color.key_flag_gray);

        // disable revoked user ids
        vName.setEnabled(false);
        vAddress.setEnabled(false);
        vComment.setEnabled(false);
    } else {
        vName.setEnabled(true);
        vAddress.setEnabled(true);
        vComment.setEnabled(true);

        if (isPrimary) {
            vName.setTypeface(null, Typeface.BOLD);
            vAddress.setTypeface(null, Typeface.BOLD);
        } else {
            vName.setTypeface(null, Typeface.NORMAL);
            vAddress.setTypeface(null, Typeface.NORMAL);
        }

        int isVerified = cursor.getInt(INDEX_VERIFIED);
        switch (isVerified) {
        case Certs.VERIFIED_SECRET:
            KeyFormattingUtils.setStatusImage(mContext, vVerified, null, State.VERIFIED,
                    KeyFormattingUtils.DEFAULT_COLOR);
            break;
        case Certs.VERIFIED_SELF:
            KeyFormattingUtils.setStatusImage(mContext, vVerified, null, State.UNVERIFIED,
                    KeyFormattingUtils.DEFAULT_COLOR);
            break;
        default:
            KeyFormattingUtils.setStatusImage(mContext, vVerified, null, State.INVALID,
                    KeyFormattingUtils.DEFAULT_COLOR);
            break;
        }
    }
}