Example usage for android.widget ImageView setBackgroundResource

List of usage examples for android.widget ImageView setBackgroundResource

Introduction

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

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:com.androprogrammer.tutorials.customviews.SlidingTabLayout.java

protected ImageView createDefaultIconTabView(Context context) {
    ImageView tabIconImageView = new ImageView(context);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        tabIconImageView.setBackgroundResource(outValue.resourceId);
    }/*from   w  w w. j  a  v  a 2  s.  c o m*/

    int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
    tabIconImageView.setPadding(padding, padding, padding, padding);

    return tabIconImageView;
}

From source file:com.android.inputmethod.keyboard.EmojiPalettesView.java

@Override
protected void onFinishInflate() {
    mTabHost = (TabHost) findViewById(R.id.emoji_category_tabhost);
    mTabHost.setup();/*from   w  ww  .  ja  va  2  s.  c om*/
    for (final CategoryProperties properties : mEmojiCategory.getShownCategories()) {
        addTab(mTabHost, properties.mCategoryId);
    }
    mTabHost.setOnTabChangedListener(this);
    mTabHost.getTabWidget().setStripEnabled(true);

    mEmojiPalettesAdapter = new EmojiPalettesAdapter(mEmojiCategory, mLayoutSet, this);

    mEmojiPager = (ViewPager) findViewById(R.id.emoji_keyboard_pager);
    mEmojiPager.setAdapter(mEmojiPalettesAdapter);
    mEmojiPager.setOnPageChangeListener(this);
    mEmojiPager.setOffscreenPageLimit(0);
    mEmojiPager.setPersistentDrawingCache(ViewPager.PERSISTENT_NO_CACHE);
    final Resources res = getResources();
    final EmojiLayoutParams emojiLp = new EmojiLayoutParams(res);
    emojiLp.setPagerProperties(mEmojiPager);

    mEmojiCategoryPageIndicatorView = (EmojiCategoryPageIndicatorView) findViewById(
            R.id.emoji_category_page_id_view);
    emojiLp.setCategoryPageIdViewProperties(mEmojiCategoryPageIndicatorView);

    setCurrentCategoryId(mEmojiCategory.getCurrentCategoryId(), true /* force */);

    final LinearLayout actionBar = (LinearLayout) findViewById(R.id.emoji_action_bar);
    emojiLp.setActionBarProperties(actionBar);

    final ImageView deleteKey = (ImageView) findViewById(R.id.emoji_keyboard_delete);
    deleteKey.setTag(Constants.CODE_DELETE);
    deleteKey.setOnTouchListener(mDeleteKeyOnTouchListener);
    final ImageView alphabetKey = (ImageView) findViewById(R.id.emoji_keyboard_alphabet);
    alphabetKey.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
    alphabetKey.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL);
    alphabetKey.setOnClickListener(this);
    final ImageView spaceKey = (ImageView) findViewById(R.id.emoji_keyboard_space);
    spaceKey.setBackgroundResource(mKeyBackgroundId);
    spaceKey.setTag(Constants.CODE_SPACE);
    spaceKey.setOnClickListener(this);
    emojiLp.setKeyProperties(spaceKey);
    final ImageView alphabetKey2 = (ImageView) findViewById(R.id.emoji_keyboard_alphabet2);
    alphabetKey2.setBackgroundResource(mEmojiFunctionalKeyBackgroundId);
    alphabetKey2.setTag(Constants.CODE_SWITCH_ALPHA_SYMBOL);
    alphabetKey2.setOnClickListener(this);
}

From source file:metrocasas.projectsgt.MainActivity.java

public void upLoadFiles() {
    bandera = true;/*from ww  w  . j a v  a  2 s.  c  om*/
    ImageView img = (ImageView) findViewById(R.id.image_load);
    assert img != null;
    img.setBackgroundResource(R.drawable.load_files);

    // Get the background, which has been compiled to an AnimationDrawable object.
    AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();

    // Start the animation (looped playback by default).
    frameAnimation.start();
    if (!title.getText().toString().equals("")) {
        q.setVisibility(View.GONE);
        p.setVisibility(View.VISIBLE);
        if (audioFile != null) {
            archivos.add(audioFile);
        } else {
            audio = "";
        }
        if (!archivos.isEmpty()) {
            try {
                for (File i : archivos) {
                    AmazonS3 s3Client = new AmazonS3Client(amazonCognito());
                    TransferUtility transferUtility = new TransferUtility(s3Client, this);
                    TransferObserver transferObserver = transferUtility.upload(BUCKET_NAME,
                            "projects/" + i.getName(), i);
                    transferObserver.setTransferListener(new TransferListener() {
                        @Override
                        public void onStateChanged(int id, TransferState state) {
                            if (state == TransferState.COMPLETED) {
                                if (bandera) {
                                    ingresarDatos();
                                    limpiarCampos();
                                    bandera = false;
                                }
                            }
                        }

                        @Override
                        public void onProgressChanged(int id, long bytesCurrent, long bytesTotal) {
                        }

                        @Override
                        public void onError(int id, Exception ex) {
                            Toast.makeText(MainActivity.this, ex.toString(), Toast.LENGTH_SHORT).show();
                        }
                    });
                }
            } catch (Exception e) {
                ingresarDatos();
                limpiarCampos();
            }
        } else {
            ingresarDatos();
            limpiarCampos();
        }
    } else {
        Toast.makeText(this, "Debe ingresar por lo menos el ttulo", Toast.LENGTH_LONG).show();
        q.scrollTo(0, 0);
        title.setFocusableInTouchMode(true);
        title.setFocusable(true);
        title.requestFocus();
    }
}

From source file:tk.melnichuk.kommunalchik.CustomViews.SlidingTabLayout.java

private void populateTabStrip() {
    PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;//from  w w w  . j  a va2s. c  o  m
        TextView tabTitleView = null;

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(R.layout.bills_menu_icon, mTabStrip, false);

            int mipmapResName = ((BillsFragment.BillsPagerAdapter) adapter).getMipMapResourceName(i);

            ImageView imageView = (ImageView) tabView;

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                // If we're running on Honeycomb or newer, then we can use the Theme's
                // selectableItemBackground to ensure that the View has a pressed state
                TypedValue outValue = new TypedValue();
                getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue,
                        true);
                imageView.setBackgroundResource(outValue.resourceId);
            }

            int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density);
            imageView.setPadding(2 * padding, padding, 2 * padding, padding);
            ;
            // imageView.setLayoutParams(mTabStrip.getLayoutParams());
            imageView.setImageResource(mipmapResName);

            tabView.setOnClickListener(tabClickListener);
            mTabStrip.addView(imageView);
            imageView.requestLayout();
            continue;
        }

        // if (tabView == null) {
        //    tabView = createDefaultTabView(getContext());
        // }

        // if (tabTitleView == null && TextView.class.isInstance(tabView)) {
        //     tabTitleView = (TextView) tabView;
        // }

        //  tabTitleView.setText(adapter.getPageTitle(i));
        // tabView.setOnClickListener(tabClickListener);

        // mTabStrip.addView(tabView);
    }
}

From source file:net.exclaimindustries.geohashdroid.wiki.WikiPictureEditor.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Get some display metrics.  We need to scale the gallery thumbnails
    // accordingly, else they look too small on big screens and too big on
    // small screens.  We do this here to save calculations later, else
    // we'd be doing floating-point multiplication on EVERY SINGLE
    // THUMBNAIL, and we can't guarantee that won't be painful on every
    // Android phone.
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    THUMB_DIMEN = (int) (getResources().getDimensionPixelSize(R.dimen.nominal_icon_size) * metrics.density);

    Log.d(DEBUG_TAG, "Thumbnail dimensions: " + THUMB_DIMEN);

    mInfo = (Info) getIntent().getParcelableExtra(GeohashDroid.INFO);

    setContentView(R.layout.pictureselect);

    Button submitButton = (Button) findViewById(R.id.wikieditbutton);
    ImageButton galleryButton = (ImageButton) findViewById(R.id.GalleryButton);

    galleryButton.setOnClickListener(new View.OnClickListener() {
        @Override//from   w w  w  . j a  v a 2s.co  m
        public void onClick(View v) {
            // Fire off the Gallery!
            startActivityForResult(new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), REQUEST_PICTURE);
        }
    });

    submitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // We don't want to let the Activity handle the dialog.  That WILL
            // cause it to show up properly and all, but after a configuration
            // change (i.e. orientation shift), it won't show or update any text
            // (as far as I know), as we can't reassign the handler properly.
            // So, we'll handle it ourselves.
            mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true, WikiPictureEditor.this);
            mConnectionHandler = new PictureConnectionRunner(mProgressHandler, WikiPictureEditor.this);
            mWikiConnectionThread = new Thread(mConnectionHandler, "WikiConnectionThread");
            mWikiConnectionThread.start();
        }
    });

    // We can set the background on the thumbnail view right away, even if
    // it's not actually visible.
    ImageView thumbView = (ImageView) findViewById(R.id.ThumbnailImage);
    thumbView.setBackgroundResource(R.drawable.gallery_selected_default);
    thumbView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

    // Now, let's see if we have anything retained...
    try {
        RetainedThings retain = (RetainedThings) getLastNonConfigurationInstance();
        if (retain != null) {
            // We have something retained!  Thus, we need to construct the
            // popup and update it with the right status, assuming the
            // thread's still going.
            if (retain.thread != null && retain.thread.isAlive()) {
                mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true,
                        WikiPictureEditor.this);
                mConnectionHandler = retain.handler;
                mConnectionHandler.resetHandler(mProgressHandler);
                mWikiConnectionThread = retain.thread;
            }

            // And in any event, put the image info back up.
            mCurrentFile = retain.currentFile;
            mCurrentThumbnail = retain.thumbnail;
            mPictureLocation = retain.picLocation;

            setThumbnail();
        } else {
            // If there was nothing to retain, maybe we've got a bundle.
            if (icicle != null) {
                if (icicle.containsKey(STORED_FILE))
                    mCurrentFile = icicle.getString(STORED_FILE);
                if (icicle.containsKey(STORED_LOCATION))
                    mPictureLocation = icicle.getParcelable(STORED_LOCATION);
            }

            // Rebuild it all in any event.
            buildThumbnail();
            setThumbnail();
        }
    } catch (Exception ex) {
        // If we got an exception, reset the thumbnail info with whatever
        // we have handy.
        buildThumbnail();
        setThumbnail();
    }

    // Rebuild the thumbnail and display it as need be.

}

From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}.//from  www  .  ja va2  s .  c  om
 */
protected ImageView createDefaultTabView(int resource) {
    ImageView imageView = new ImageView(getContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1));
    imageView.setImageResource(resource);
    if (tabViewBackgroundResId != NO_ID) {
        imageView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        imageView.setBackgroundResource(outValue.resourceId);
    }

    imageView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        imageView.setMinimumWidth(tabViewTextMinWidth);
    }

    return imageView;
}

From source file:app.jorge.mobile.com.transportalert.DetailActivity.java

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

    ImageView imageView = (ImageView) findViewById(R.id.iconTube);
    TextView textTubeName = (TextView) findViewById(R.id.tubeName);
    TextView textStatusView = (TextView) findViewById(R.id.tubeStatus);

    String category = getCategory(getIntent().getStringExtra(getString(R.string.activity_info_category)));
    String description = getDescription(
            getIntent().getStringExtra(getString(R.string.activity_info_description)));
    String additional = getIntent().getStringExtra(getString(R.string.activity_info_additional));
    String name = getIntent().getStringExtra(getString(R.string.activity_info_icon));
    String status = getIntent().getStringExtra(getString(R.string.activity_info_status));

    textTubeName.setText(name);//from  www  .  j av  a 2  s.c o  m
    textStatusView.setText(status);
    imageView.setBackgroundResource(getIconLine(name));

    TextView textCategoryView = (TextView) findViewById(R.id.category);
    textCategoryView.setText(category);

    TextView textDescriptionView = (TextView) findViewById(R.id.description);
    textDescriptionView.setText(description);

    TextView textAdditionalView = (TextView) findViewById(R.id.additional);
    textAdditionalView.setText(additional);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        imageView.setTransitionName(getString(R.string.activity_image_trans));
        textTubeName.setTransitionName(getString(R.string.activity_text_tube_name));
        textStatusView.setTransitionName(getString(R.string.activity_text_tube_status));

    }

}

From source file:com.gh4a.IssueActivity.java

private void fillData() {
    new LoadCommentsTask(this).execute();

    Typeface boldCondensed = getApplicationContext().boldCondensed;

    ListView lvComments = (ListView) findViewById(R.id.list_view);
    // set details inside listview header
    LayoutInflater infalter = getLayoutInflater();
    LinearLayout mHeader = (LinearLayout) infalter.inflate(R.layout.issue_header, lvComments, false);
    mHeader.setClickable(false);//from   ww  w .j  a v a  2 s . com

    lvComments.addHeaderView(mHeader, null, false);

    RelativeLayout rlComment = (RelativeLayout) findViewById(R.id.rl_comment);
    if (!isAuthorized()) {
        rlComment.setVisibility(View.GONE);
    }

    TextView tvCommentTitle = (TextView) mHeader.findViewById(R.id.comment_title);
    mCommentAdapter = new CommentAdapter(IssueActivity.this, new ArrayList<Comment>(), mIssue.getNumber(),
            mIssue.getState(), mRepoOwner, mRepoName);
    lvComments.setAdapter(mCommentAdapter);

    ImageView ivGravatar = (ImageView) mHeader.findViewById(R.id.iv_gravatar);
    aq.id(R.id.iv_gravatar).image(GravatarUtils.getGravatarUrl(mIssue.getUser().getGravatarId()), true, false,
            0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

    ivGravatar.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getUser().getLogin(), null);
        }
    });

    TextView tvExtra = (TextView) mHeader.findViewById(R.id.tv_extra);
    TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state);
    TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title);
    TextView tvDescTitle = (TextView) mHeader.findViewById(R.id.desc_title);
    tvDescTitle.setTypeface(getApplicationContext().boldCondensed);
    tvDescTitle.setTextColor(Color.parseColor("#0099cc"));

    tvCommentTitle.setTypeface(getApplicationContext().boldCondensed);
    tvCommentTitle.setTextColor(Color.parseColor("#0099cc"));
    tvCommentTitle
            .setText(getResources().getString(R.string.issue_comments) + " (" + mIssue.getComments() + ")");

    TextView tvDesc = (TextView) mHeader.findViewById(R.id.tv_desc);
    tvDesc.setMovementMethod(LinkMovementMethod.getInstance());

    TextView tvMilestone = (TextView) mHeader.findViewById(R.id.tv_milestone);

    ImageView ivComment = (ImageView) findViewById(R.id.iv_comment);
    if (Gh4Application.THEME == R.style.DefaultTheme) {
        ivComment.setImageResource(R.drawable.social_send_now_dark);
    }
    ivComment.setBackgroundResource(R.drawable.abs__list_selector_holo_dark);
    ivComment.setPadding(5, 2, 5, 2);
    ivComment.setOnClickListener(this);

    tvExtra.setText(mIssue.getUser().getLogin() + "\n" + pt.format(mIssue.getCreatedAt()));
    tvState.setTextColor(Color.WHITE);
    if ("closed".equals(mIssue.getState())) {
        tvState.setBackgroundResource(R.drawable.default_red_box);
        tvState.setText("C\nL\nO\nS\nE\nD");
    } else {
        tvState.setBackgroundResource(R.drawable.default_green_box);
        tvState.setText("O\nP\nE\nN");
    }
    tvTitle.setText(mIssue.getTitle());
    tvTitle.setTypeface(boldCondensed);

    boolean showInfoBox = false;
    if (mIssue.getAssignee() != null) {
        showInfoBox = true;
        TextView tvAssignee = (TextView) mHeader.findViewById(R.id.tv_assignee);
        tvAssignee.setText(mIssue.getAssignee().getLogin() + " is assigned");
        tvAssignee.setVisibility(View.VISIBLE);
        tvAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });

        ImageView ivAssignee = (ImageView) mHeader.findViewById(R.id.iv_assignee);

        aq.id(R.id.iv_assignee).image(GravatarUtils.getGravatarUrl(mIssue.getAssignee().getGravatarId()), true,
                false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN);

        ivAssignee.setVisibility(View.VISIBLE);
        ivAssignee.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                getApplicationContext().openUserInfoActivity(IssueActivity.this,
                        mIssue.getAssignee().getLogin(), null);
            }
        });
    }

    if (mIssue.getMilestone() != null) {
        showInfoBox = true;
        tvMilestone.setText(
                getResources().getString(R.string.issue_milestone) + ": " + mIssue.getMilestone().getTitle());
    } else {
        tvMilestone.setVisibility(View.GONE);
    }

    String body = mIssue.getBodyHtml();
    if (!StringUtils.isBlank(body)) {
        HttpImageGetter imageGetter = new HttpImageGetter(this);
        body = HtmlUtils.format(body).toString();
        imageGetter.bind(tvDesc, body, mIssue.getNumber());
    }

    LinearLayout llLabels = (LinearLayout) findViewById(R.id.ll_labels);
    List<Label> labels = mIssue.getLabels();

    if (labels != null && !labels.isEmpty()) {
        showInfoBox = true;
        for (Label label : labels) {
            TextView tvLabel = new TextView(this);
            tvLabel.setSingleLine(true);
            tvLabel.setText(label.getName());
            tvLabel.setTextAppearance(this, R.style.default_text_small);
            tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor()));
            tvLabel.setPadding(5, 2, 5, 2);
            int r = Color.red(Color.parseColor("#" + label.getColor()));
            int g = Color.green(Color.parseColor("#" + label.getColor()));
            int b = Color.blue(Color.parseColor("#" + label.getColor()));
            if (r + g + b < 383) {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_dark));
            } else {
                tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_light));
            }
            llLabels.addView(tvLabel);

            View v = new View(this);
            v.setLayoutParams(new LayoutParams(5, LayoutParams.WRAP_CONTENT));
            llLabels.addView(v);
        }
    } else {
        llLabels.setVisibility(View.GONE);
    }

    TextView tvPull = (TextView) mHeader.findViewById(R.id.tv_pull);
    if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) {
        showInfoBox = true;
        tvPull.setVisibility(View.VISIBLE);
        tvPull.setOnClickListener(this);
    }

    if (!showInfoBox) {
        RelativeLayout rl = (RelativeLayout) mHeader.findViewById(R.id.info_box);
        rl.setVisibility(View.GONE);
    }
}

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

private void addWarningTab(final int position, String title, int resId) {
    LinearLayout tabLayout = new LinearLayout(getContext());
    tabLayout.setOrientation(LinearLayout.HORIZONTAL);
    tabLayout.setGravity(Gravity.CENTER);

    ImageView tabImg = new ImageView(getContext());
    int width = DimenUtils.dp2px(getContext(), 18);
    LinearLayout.LayoutParams tabImgParams = new LinearLayout.LayoutParams(width, width);
    tabImgParams.setMargins(0, 0, DimenUtils.dp2px(getContext(), 10), 0);
    tabImgParams.gravity = Gravity.CENTER;
    tabImg.setLayoutParams(tabImgParams);
    if (resId != -1) {
        tabImg.setBackgroundResource(resId);
        tabImg.setVisibility(View.VISIBLE);
    } else {//from w  w w. j  a va2s. c o  m
        tabImg.setVisibility(View.GONE);
    }
    tabLayout.addView(tabImg, 0);

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setFocusable(true);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();
    tab.setTextColor(getResources().getColorStateList(
            mTextChangeable ? R.color.pst_tab_changeable_text_selector : R.color.pst_tab_text_selector));
    tab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18.0f);
    tabLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });
    tabLayout.addView(tab, 1);

    tabsContainer.addView(tabLayout);
}

From source file:com.seekon.yougouhui.activity.shop.RegisterShopActivity.java

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private String addShopIconToView(final ImageView imageView, final ImageButton delButton, Intent data) {
    String iconPath = null;//from   w ww . j av  a 2s  .  com
    Uri selectedImage = data.getData();
    String[] filePathColumn = { MediaStore.Images.Media.DATA };
    Cursor cursor = null;
    try {
        cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
        cursor.moveToFirst();
        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        iconPath = cursor.getString(columnIndex);
    } finally {
        cursor.close();
    }

    imageView.setBackgroundResource(0);
    imageView.setBackground(
            new BitmapDrawable(FileHelper.decodeFile(iconPath, true, SHOP_ICON_WIDTH, SHOP_ICON_WIDTH)));

    delButton.setVisibility(View.VISIBLE);
    delButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            imageView.setBackgroundResource(R.drawable.add_camera);
            delButton.setVisibility(View.GONE);

            int viewId = v.getId();
            if (viewId == R.id.shop_busi_license_del) {
                busiLicense = null;
            } else if (viewId == R.id.shop_image_del) {
                shopImage = null;
            }
        }
    });
    return iconPath;
}