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.wisc.cs407project.ImageLoader.ImageLoader.java

public void DisplayImage(ScaleObject scaleObject, ImageView imageView) {
    imageViews.put(imageView, scaleObject.imageLocation);
    Bitmap bitmap = memoryCache.get(scaleObject.imageLocation);
    if (bitmap != null) {
        scaleObject.image = bitmap;//from  w  w w.ja va  2  s  .  c  o  m
        imageView.setImageBitmap(bitmap);
        imageView.setBackgroundResource(R.drawable.gray_image_border);
    } else {
        queuePhoto(scaleObject, imageView);
    }
}

From source file:com.bb.hbx.activitiy.InsurancePlanActivity.java

@Override
protected void onRestart() {
    super.onRestart();
    ImageView dotView = new ImageView(mContext);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(10, 10);
    lp.leftMargin = 10;// ww w. j a v a 2s  .com
    dotView.setLayoutParams(lp);
    dotView.setBackgroundResource(R.drawable.dot_selected);
    dotView.setAlpha(0.38f);
    dotList.add(dotView);
    lin_add.addView(dotView);
    ComCarPropsBean.PlanListBean newBean = new ComCarPropsBean.PlanListBean();
    newBean.setSyxList(customSyxPlan);
    newBean.setJqxList(customJqxPlan);
    newBean.setFjxList(customFjxPlan);
    newBean.setQtxList(customQtxPlan);
    //planList.add(newBean);
    planList.add(prePosition, newBean);
    //?
    mCardAdapter.addViewCount();
    mCardAdapter.notifyDataSetChanged();
    vp_tb.setCurrentItem(prePosition);
}

From source file:com.yahala.ui.Views.EmojiViewExtra.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    loadRecents();//from  ww  w.  j av  a 2  s.  co m
    setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] {
            Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666") }));

    emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().categories);
    pager = new ViewPager(getContext());
    pager.setOffscreenPageLimit(5);
    pager.setAdapter(emojiPagerAdapter);
    FileLog.e("EmojiManager.emojiGroups", "" + EmojiManager.getInstance().categories.size());
    PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(false);
    tabs.setMinimumWidth(OSUtilities.dp(50));
    tabs.setTabPaddingLeftRight(OSUtilities.dp(10));
    tabs.setIndicatorHeight(3);
    //tabs.setTabBackground(Color.parseColor("#FF3f9fe0"));
    tabs.setTabBackground(R.drawable.bar_selector_main);

    tabs.setIndicatorColor(Color.parseColor("#FFffffff"));
    tabs.setDividerColor(Color.parseColor("#ff222222"));
    tabs.setUnderlineHeight(2);
    tabs.setUnderlineColor(Color.parseColor("#ff373737"));

    //tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            if (EmojiViewExtra.this.listener != null) {
                EmojiViewExtra.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT));
    /* recentsWrap = new FrameLayout(getContext());
     recentsWrap.addView(views.get(0));
     TextView localTextView = new TextView(getContext());
     localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
     localTextView.setTextSize(18.0f);
     localTextView.setTextColor(-7829368);
     localTextView.setGravity(17);
     recentsWrap.addView(localTextView);
     views.get(0).setEmptyView(localTextView);*/
    addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f)));

    addView(pager);

    if (!EmojiManager.getInstance().categoriesDict.containsKey("recents")
            || EmojiManager.getInstance().categoriesDict.get("recents").emojis.size() == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:com.filemanager.free.adapters.DrawerAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    if (values.get(position).isSection()) {
        ImageView view = new ImageView(context);
        if (m.theme1 == 0)
            view.setImageResource(R.color.divider);
        else//from  w  w w .  j a va2  s .c  o m
            view.setImageResource(R.color.divider_dark);
        view.setClickable(false);
        view.setFocusable(false);
        if (m.theme1 == 0)
            view.setBackgroundColor(Color.WHITE);
        else
            view.setBackgroundResource(R.color.background_material_dark);
        view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17)));
        view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8));
        return view;
    } else {
        View view = inflater.inflate(R.layout.drawerrow, parent, false);
        final TextView txtTitle = (TextView) view.findViewById(R.id.firstline);
        final ImageView imageView = (ImageView) view.findViewById(R.id.icon);
        if (m.theme1 == 0) {
            view.setBackgroundResource(R.drawable.safr_ripple_white);
        } else {
            view.setBackgroundResource(R.drawable.safr_ripple_black);
        }
        view.setOnClickListener(new View.OnClickListener() {

            public void onClick(View p1) {
                m.selectItem(position);
            }
            // TODO: Implement this method

        });
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (!getItem(position).isSection())
                    // not to remove the first bookmark (storage) and permanent bookmarks
                    if (position > m.storage_count && position < values.size() - 7) {
                        EntryItem item = (EntryItem) getItem(position);
                        String path = (item).getPath();
                        if (DataUtils.containsBooks(new String[] { item.getTitle(), path }) != -1) {
                            m.renameBookmark((item).getTitle(), path);
                        } else if (path.startsWith("smb:/")) {
                            m.showSMBDialog(item.getTitle(), path, true);
                        }
                    } else if (position < m.storage_count) {
                        String path = ((EntryItem) getItem(position)).getPath();
                        if (!path.equals("/"))
                            new Futils().showProps(RootHelper.generateBaseFile(new File(path), true), m,
                                    m.theme1);
                    }

                // return true to denote no further processing
                return true;
            }
        });

        txtTitle.setText(((EntryItem) (values.get(position))).getTitle());
        imageView.setImageDrawable(getDrawable(position));
        imageView.clearColorFilter();
        if (myChecked.get(position)) {
            if (m.theme1 == 0)
                view.setBackgroundColor(Color.parseColor("#ffeeeeee"));
            else
                view.setBackgroundColor(Color.parseColor("#ff424242"));
            imageView.setColorFilter(fabskin);
            txtTitle.setTextColor(Color.parseColor(m.fabskin));
        } else {
            if (m.theme1 == 0) {
                imageView.setColorFilter(Color.parseColor("#666666"));
                txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black));
            } else {
                imageView.setColorFilter(Color.WHITE);
                txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white));
            }
        }

        return view;
    }
}

From source file:com.peppermint.peppermint.ui.CallFragment.java

/**
 * Updates the status box at the top of the UI with a messege of your choice.
 * @param status The String to display in the status box.
 *//*from  w w w  . ja  v a  2  s  .  c  om*/
public void updateStatus(final String status) {
    // Be a good citizen.  Make sure UI changes fire on the UI thread.
    getActivity().runOnUiThread(new Runnable() {
        public void run() {
            TextView labelView = (TextView) rootView.findViewById(R.id.sipLabel);
            labelView.setText(status);

            //the ImageView for illustrating the call-state

            ImageView callStateImage = (ImageView) rootView.findViewById(R.id.callStateImage);
            if ((call != null) && call.isInCall()) {
                callStateImage.setBackgroundResource(R.drawable.btn_speak_pressed);
            } else {
                callStateImage.setBackgroundResource(R.drawable.btn_speak_normal);
            }

        }
    });
}

From source file:org.safegees.safegees.gui.fragment.ProfileContactFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_profile_contact, container, false);

    ArrayList<Friend> friends = SafegeesDAO.getInstance(view.getContext()).getMutualFriends();

    Friend friend = friends.get(position);

    //this.getActivity().onBackPressed();

    //ImageButton closeContact = (ImageButton) view.findViewById(R.id.close_contact);
    //closeContact.setOnClickListener(this);

    imageView = (ImageView) view.findViewById(R.id.result);
    editName = (EditText) view.findViewById(R.id.editName);
    editSurname = (EditText) view.findViewById(R.id.editSurname);
    editEmail = (EditText) view.findViewById(R.id.editEmail);
    editPhone = (EditText) view.findViewById(R.id.editPhone);
    editTopic = (TextView) view.findViewById(R.id.editTopic);

    LinearLayout llName = (LinearLayout) view.findViewById(R.id.lay_name);
    LinearLayout llSurname = (LinearLayout) view.findViewById(R.id.lay_surname);
    LinearLayout llMail = (LinearLayout) view.findViewById(R.id.lay_mail);
    LinearLayout llPhone = (LinearLayout) view.findViewById(R.id.lay_phone);
    //LinearLayout llBio = (LinearLayout) view.findViewById(R.id.lay_topic);

    //Show arrows to reveal user if there are more contacts
    ImageView arrowLeft = (ImageView) view.findViewById(R.id.contact_left);
    ImageView arrowRight = (ImageView) view.findViewById(R.id.contact_right);

    //Change arrows if Language is LTR (Ar or FA)
    //And reveal the accurate arrow
    if (TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL) {
        arrowLeft.setBackgroundResource(R.drawable.ic_chevron_right_black_24dp);
        arrowRight.setBackgroundResource(R.drawable.ic_chevron_left_black_24dp);
        if (position == 0)
            arrowRight.setVisibility(View.INVISIBLE);
        if (position == friends.size() - 1)
            arrowLeft.setVisibility(View.INVISIBLE);
    } else {//  ww w.  j  a  v a 2 s. c  o  m
        if (position == 0)
            arrowLeft.setVisibility(View.INVISIBLE);
        if (position == friends.size() - 1)
            arrowRight.setVisibility(View.INVISIBLE);
    }

    if (friend != null) {
        this.editName.setText(friend.getName() != null ? friend.getName() : "");
        this.editSurname.setText(friend.getSurname() != null ? friend.getSurname() : "");
        this.editEmail.setText(friend.getPublicEmail() != null ? friend.getPublicEmail() : "");
        this.editPhone.setText(friend.getPhoneNumber() != null ? friend.getPhoneNumber() : "");
        this.editTopic.setText(friend.getBio() != null ? "\"" + friend.getBio() + "\"" : "");
        ViewGroup.LayoutParams params = editTopic.getLayoutParams();
        params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        editTopic.setLayoutParams(params);
    }

    if (friend.getName() == null || friend.getName().equals(""))
        llName.setVisibility(View.GONE);
    if (friend.getSurname() == null || friend.getSurname().equals(""))
        llSurname.setVisibility(View.GONE);
    if (friend.getPublicEmail() == null || friend.getPublicEmail().equals(""))
        llMail.setVisibility(View.GONE);
    if (friend.getPhoneNumber() == null || friend.getPhoneNumber().equals(""))
        llPhone.setVisibility(View.GONE);
    if (friend.getBio() == null || friend.getBio().equals(""))
        editTopic.setVisibility(View.GONE);

    //Add image from friend
    if (friend.getPublicEmail() != null) {
        Bitmap bitmap = ImageController.getContactImageBitmap(getContext(), friend.getPublicEmail());
        if (bitmap != null)
            this.imageView.setImageBitmap(bitmap);
    }

    // Inflate the layout for this fragment
    return view;
}

From source file:com.almeida.matheus.androidslidingtabmaterialdesigner.Components.SlidingTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link (int, int)}./*from w w  w  .  ja  va  2 s .co m*/
 */
protected ImageView createDefaultTabView(Context context) {
    ImageView iconTab = new ImageView(context);
    iconTab.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    TypedValue outValue = new TypedValue();
    getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
    iconTab.setBackgroundResource(outValue.resourceId);

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

    return iconTab;
}

From source file:com.yahala.ui.Views.StickersView.java

private void init() {
    setOrientation(LinearLayout.VERTICAL);
    loadRecents();/*from  ww  w. ja v  a 2  s  . c  om*/
    setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] {
            Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666") }));

    emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().stickersCategories);
    pager = new ViewPager(getContext());
    pager.setAdapter(emojiPagerAdapter);
    FileLog.e("EmojiManager.stickersCategories", "" + EmojiManager.getInstance().stickersCategories.size());
    PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext());
    tabs.setViewPager(pager);
    tabs.setShouldExpand(false);
    tabs.setMinimumWidth(OSUtilities.dp(50));
    tabs.setTabPaddingLeftRight(OSUtilities.dp(10));
    tabs.setIndicatorHeight(3);
    //tabs.setTabBackground(Color.parseColor("#FF3f9fe0"));
    tabs.setTabBackground(R.drawable.bar_selector_main);

    tabs.setIndicatorColor(Color.parseColor("#FFffffff"));
    tabs.setDividerColor(Color.parseColor("#ff222222"));
    tabs.setUnderlineHeight(2);
    tabs.setUnderlineColor(Color.parseColor("#ff373737"));

    //tabs.setTabBackground(0);
    LinearLayout localLinearLayout = new LinearLayout(getContext());
    localLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    localLinearLayout.addView(tabs,
            new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
    ImageView localImageView = new ImageView(getContext());
    localImageView.setImageResource(R.drawable.ic_emoji_backspace);
    localImageView.setScaleType(ImageView.ScaleType.CENTER);
    localImageView.setBackgroundResource(R.drawable.bg_emoji_bs);
    localImageView.setOnClickListener(new OnClickListener() {
        public void onClick(View view) {
            if (StickersView.this.listener != null) {
                StickersView.this.listener.onBackspace();
            }
        }
    });
    localLinearLayout.addView(localImageView,
            new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT));
    /* recentsWrap = new FrameLayout(getContext());
     recentsWrap.addView(views.get(0));
     TextView localTextView = new TextView(getContext());
     localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent));
     localTextView.setTextSize(18.0f);
     localTextView.setTextColor(-7829368);
     localTextView.setGravity(17);
     recentsWrap.addView(localTextView);
     views.get(0).setEmptyView(localTextView);*/
    addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f)));

    addView(pager);

    if (!EmojiManager.getInstance().stickersCategoriesDict.containsKey("recents")
            || EmojiManager.getInstance().stickersCategoriesDict.get("recents").stickers.size() == 0) {
        pager.setCurrentItem(1);
    }
}

From source file:com.inc.playground.playground.MainActivity.java

public void setPlayGroundActionBar() {
    String userLoginId, userFullName, userEmail, userPhoto;
    Bitmap imageBitmap = null;//from w  w w  .j  ava  2  s.  c o m
    GlobalVariables globalVariables;
    final ActionBar actionBar = getActionBar();

    final String MY_PREFS_NAME = "Login";
    SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
    globalVariables = ((GlobalVariables) this.getApplication());
    if (prefs.getString("userid", null) != null) {
        userLoginId = prefs.getString("userid", null);
        userFullName = prefs.getString("fullname", null);
        userEmail = prefs.getString("emilid", null);
        userPhoto = prefs.getString("picture", null);
        globalVariables.GetCurrentUser().setPhotoUrl(userPhoto);
        actionBar.setCustomView(R.layout.actionbar_custom_view_home);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);

        ImageView logo_image = (ImageView) findViewById(R.id.img_profile_action_bar);
        logo_image.setBackgroundResource(R.drawable.pg_logo2);
        TextView userName = (TextView) findViewById(R.id.email);
        userName.setText(userFullName.replace("%20", "  "));
        ImageView img_profile = (ImageView) findViewById(R.id.profile_image);
        imageBitmap = globalVariables.GetUserPictureBitMap();
        if (imageBitmap == null) {
            Log.i(TAG, "downloading");
            try {
                imageBitmap = new DownloadImageBitmapTask().execute(userPhoto).get();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }

        } else {
            Log.i(TAG, "Image found");
        }
        img_profile.setImageBitmap(imageBitmap);

        ImageView notificationBtn = (ImageView) findViewById(R.id.notification_btn);
        notificationBtn.setVisibility(View.VISIBLE);
        notificationBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent iv = new Intent(MainActivity.this, NotificationsList.class);
                startActivity(iv);
                finish();
            }
        });
        TextView notificationNumber = (TextView) findViewById(R.id.notification__numberTxt);
        if (globalVariables.GetNotifications() != null && globalVariables.GetNotifications().size() != 0) {
            notificationNumber.setText(Integer.toString(globalVariables.GetNotifications().size()));
            notificationNumber.setVisibility(View.VISIBLE);
        } else {
            notificationNumber.setVisibility(View.INVISIBLE);
        }

        TextView loginTxt = (TextView) findViewById(R.id.login_txt);
        ImageView loginImg = (ImageView) findViewById(R.id.login_img);
        globalVariables.SetUserPictureBitMap(imageBitmap); // Make the imageBitMap global to all activities to avoid downloading twice
        loginTxt.setText("Logout");
        loginImg.setImageResource(R.drawable.pg_action_lock_close);
        // Register to notifications
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);

    }
}

From source file:com.cricketkorner.cricket.VitamioListActivity.java

private void ListFunction() {

    listView = (ListView) findViewById(R.id.listView);
    //copying array 
    for (int i = 0; i < Singleton.getInstance().getChannelList().size(); i++) {

        title.add(Singleton.getInstance().getChannelList().get(i).getChannelName());
        desc.add("Long Press This Channel To Report, Id: "
                + Singleton.getInstance().getChannelList().get(i).getChannelId());
        thumb.add(R.drawable.ic_launcher);
    }/*from   w w  w .j av a2s .  c o m*/
    listView.setAdapter(new VersionAdapter(VitamioListActivity.this));

    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {
            AlertDialog.Builder alert = new AlertDialog.Builder(VitamioListActivity.this);

            alert.setTitle("Report Broken Link");
            alert.setMessage("Message: (Channel not working?)");

            // Set an EditText view to get user input 
            final EditText input = new EditText(VitamioListActivity.this);
            alert.setView(input);

            alert.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = input.getText().toString();
                    if (isNetworkAvailable()) {
                        new ReportFeedback().execute("http://yoururl.com/LiveStreaming/reportFeedback.php",
                                value, Singleton.getInstance().getChannelList().get(position).getChannelId());
                    }
                }
            });

            alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    // Canceled.
                }
            });
            alert.show();
            return false;
        }
    });

    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            int pos = arg2;

            LayoutInflater layoutInflator = getLayoutInflater();

            View layout = layoutInflator.inflate(R.layout.custom_toast,
                    (ViewGroup) findViewById(R.id.toast_layout_root));

            ImageView iv = (ImageView) layout.findViewById(R.id.toast_iv);
            TextView tv = (TextView) layout.findViewById(R.id.toast_tv);

            iv.setBackgroundResource(thumb.get(pos));
            tv.setText(title.get(pos));
            Intent intent = new Intent(VitamioListActivity.this, VideoViewDemo.class);
            intent.putExtra("path", Singleton.getInstance().getChannelList().get(pos).getChannelPath());
            startAppAd.onBackPressed();
            startActivity(intent);
        }
    });
}