Example usage for android.widget ImageView setImageResource

List of usage examples for android.widget ImageView setImageResource

Introduction

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

Prototype

@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync")
public void setImageResource(@DrawableRes int resId) 

Source Link

Document

Sets a drawable as the content of this ImageView.

Usage

From source file:com.layer.atlas.messenger.AtlasMessagesScreen.java

private void prepareActionBar() {
    ImageView menuBtn = (ImageView) findViewById(R.id.atlas_actionbar_left_btn);
    menuBtn.setImageResource(R.drawable.atlas_ctl_btn_back);
    menuBtn.setVisibility(View.VISIBLE);
    menuBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();//www.  java  2  s . c o m
        }
    });
    ((TextView) findViewById(R.id.atlas_actionbar_title_text)).setText("Messages");
    ((TextView) findViewById(R.id.atlas_actionbar_title_text)).setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            messagesList.requestRefreshValues(true, false);
        }
    });
    ImageView settingsBtn = (ImageView) findViewById(R.id.atlas_actionbar_right_btn);
    settingsBtn.setImageResource(R.drawable.atlas_ctl_btn_detail);
    settingsBtn.setVisibility(View.VISIBLE);
    settingsBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (conv == null)
                return;
            AtlasConversationSettingsScreen.conv = conv;
            Intent intent = new Intent(v.getContext(), AtlasConversationSettingsScreen.class);
            startActivityForResult(intent, REQUEST_CODE_SETTINGS);
        }
    });
    Tools.setStatusBarColor(getWindow(), getResources().getColor(R.color.atlas_background_blue_dark));
}

From source file:com.odoo.OdooActivity.java

private View generateView(String title, int res_id) {
    View view = LayoutInflater.from(this).inflate(R.layout.base_drawer_account_item, mDrawerAccountContainer,
            false);//from  ww  w . j a v a 2s. c o m
    OControls.setGone(view, R.id.profile_url_text);
    ImageView icon = (ImageView) view.findViewById(R.id.profile_image);
    icon.setImageResource(res_id);
    icon.setColorFilter(OResource.color(this, R.color.body_text_2));
    TextView name = (TextView) view.findViewById(R.id.profile_name_text);
    name.setTypeface(name.getTypeface(), Typeface.BOLD);
    name.setText(title);
    return view;
}

From source file:com.google.android.apps.mytracks.io.sendtogoogle.UploadResultActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id != DIALOG_RESULT_ID) {
        return null;
    }/*  ww w  .jav  a 2 s. c o m*/
    view = getLayoutInflater().inflate(R.layout.upload_result, null);

    LinearLayout mapsResult = (LinearLayout) view.findViewById(R.id.upload_result_maps_result);

    ImageView mapsResultIcon = (ImageView) view.findViewById(R.id.upload_result_maps_result_icon);

    TextView successFooter = (TextView) view.findViewById(R.id.upload_result_success_footer);
    TextView errorFooter = (TextView) view.findViewById(R.id.upload_result_error_footer);

    boolean hasError = false;
    if (!sendRequest.isSendNogago()) {
        mapsResult.setVisibility(View.GONE);
    } else {
        if (!sendRequest.isNogagoSuccess()) {
            mapsResultIcon.setImageResource(R.drawable.failure);
            mapsResultIcon.setContentDescription(getString(R.string.generic_error_title));
            hasError = true;
        }
    }

    if (hasError) {
        successFooter.setVisibility(View.GONE);
    } else {
        errorFooter.setVisibility(View.GONE);
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true)
            .setIcon(hasError ? android.R.drawable.ic_dialog_alert : android.R.drawable.ic_dialog_info)
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    finish();
                }
            }).setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            }).setNeutralButton(R.string.dlg_btn_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                    Intent settings = new Intent(UploadResultActivity.this, SettingsActivity.class);
                    startActivity(settings);
                }
            }).setTitle(hasError ? R.string.generic_error_title : R.string.generic_success_title).setView(view);

    // Add a Share URL button if shareUrl exists
    if (shareUrl != null) {
        builder.setNegativeButton(R.string.share_track_share_url, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                ChooseActivityDialogFragment.newInstance(sendRequest.getTrackId(), shareUrl).show(
                        getSupportFragmentManager(), ChooseActivityDialogFragment.CHOOSE_ACTIVITY_DIALOG_TAG);
            }
        });
    }
    resultDialog = builder.create();
    return resultDialog;
}

From source file:com.google.dotorg.crisisresponse.translationcards.RecordingActivity.java

private void setLabelNextButtonEnabled(boolean enabled) {
    TextView text = (TextView) findViewById(R.id.recording_label_next_text);
    ImageView image = (ImageView) findViewById(R.id.recording_label_next_image);
    if (enabled) {
        text.setTextColor(getResources().getColor(R.color.primaryTextColor));
        image.setImageResource(R.drawable.forward_arrow);
    } else {//from  w  ww.j  a va2 s  . c om
        text.setTextColor(getResources().getColor(R.color.navBarTextDisabled));
        image.setImageResource(R.drawable.forward_arrow_40p);
    }
}

From source file:com.haomee.view.PagerSlidingTabStrip.java

private void addTextIconTab(final int position, String title, int resId) {

    if (resId == TitleIconTabProvider.NONE_ICON) {
        addTextTab(position, title);/*from  www.jav  a2s.co  m*/
        return;
    }

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    ImageView icon = new ImageView(getContext());
    icon.setImageResource(resId);

    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    linearLayout.addView(tab, defaultTabLayoutParams);
    linearLayout.addView(icon, defaultTabLayoutParams);

    addTab(position, linearLayout);
}

From source file:com.esri.android.mapsapp.MapsAppActivity.java

/**
 * Updates the navigation drawer items.//  ww  w  .  j  a  v  a  2s. c  o m
 */
private void updateDrawer() {
    mDrawerItems.clear();

    DrawerItem item;
    if (AccountManager.getInstance().isSignedIn()) {

        // user info
        LinearLayout userInfoView = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_user_layout,
                null);
        TextView textView = (TextView) userInfoView.findViewById(R.id.drawer_item_fullname_textview);
        textView.setText(AccountManager.getInstance().getPortalUser().getFullName());

        textView = (TextView) userInfoView.findViewById(R.id.drawer_item_username_textview);
        textView.setText(AccountManager.getInstance().getPortalUser().getUsername());

        item = new DrawerItem(userInfoView, null);
        mDrawerItems.add(item);

        // Sign Out

        LinearLayout view_signOut = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout,
                null);
        TextView text_drawer_signOut = (TextView) view_signOut.findViewById(R.id.drawer_item_textview);
        ImageView icon_drawer_signOut = (ImageView) view_signOut.findViewById(R.id.drawer_item_icon);

        text_drawer_signOut.setText(getString(R.string.sign_out));
        icon_drawer_signOut.setImageResource(R.drawable.ic_profile);
        item = new DrawerItem(view_signOut, new DrawerItem.OnClickListener() {

            @Override
            public void onClick() {
                signOut();
            }
        });
        mDrawerItems.add(item);

        // My Maps
        LinearLayout view_myMaps = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout,
                null);
        TextView text_drawer_myMaps = (TextView) view_myMaps.findViewById(R.id.drawer_item_textview);
        ImageView icon_drawer_myMaps = (ImageView) view_myMaps.findViewById(R.id.drawer_item_icon);

        text_drawer_myMaps.setText(getString(R.string.my_maps));
        icon_drawer_myMaps.setImageResource(R.drawable.ic_map32);
        item = new DrawerItem(view_myMaps, new DrawerItem.OnClickListener() {

            @Override
            public void onClick() {
                showContentBrowser();
            }
        });
        mDrawerItems.add(item);
    } else {

        // Adding the Sign In item in the drawer
        LinearLayout view_signIn = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout,
                null);
        TextView text_drawer_signIn = (TextView) view_signIn.findViewById(R.id.drawer_item_textview);
        ImageView icon_drawer_signIn = (ImageView) view_signIn.findViewById(R.id.drawer_item_icon);

        text_drawer_signIn.setText(getString(R.string.sign_in));
        icon_drawer_signIn.setImageResource(R.drawable.ic_profile);
        item = new DrawerItem(view_signIn, new DrawerItem.OnClickListener() {

            @Override
            public void onClick() {
                showSignInActivity();
            }
        });
        mDrawerItems.add(item);
    }

    // Adding the basemap item in the drawer
    LinearLayout view_basemap = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout, null);
    TextView text_drawer_basemap = (TextView) view_basemap.findViewById(R.id.drawer_item_textview);
    ImageView icon_drawer_basemap = (ImageView) view_basemap.findViewById(R.id.drawer_item_icon);
    text_drawer_basemap.setText(getString(R.string.menu_basemaps));
    icon_drawer_basemap.setImageResource(R.drawable.action_basemaps);
    item = new DrawerItem(view_basemap, new DrawerItem.OnClickListener() {

        @Override
        public void onClick() {
            // Show BasemapsDialogFragment to offer a choice if basemaps.
            // This calls back to onBasemapChanged() if one is selected.
            BasemapsDialogFragment basemapsFrag = new BasemapsDialogFragment();
            basemapsFrag.setBasemapsDialogListener(new BasemapsDialogFragment.BasemapsDialogListener() {

                @Override
                public void onBasemapChanged(String itemId) {
                    showMap(null, itemId);
                }
            });
            basemapsFrag.show(getFragmentManager(), null);
            mDrawerLayout.closeDrawers();
        }

    });

    mDrawerItems.add(item);

    BaseAdapter adapter = (BaseAdapter) mDrawerList.getAdapter();
    if (adapter == null) {
        adapter = new DrawerItemListAdapter();
        mDrawerList.setAdapter(adapter);
    } else {
        adapter.notifyDataSetChanged();
    }
}

From source file:com.astuetz.PagerSlidingTitleIconTabStrip.java

private void addTextIconTab(final int position, String title, int resId) {

    if (resId == TitleIconTabProvider.NONE_ICON) {
        addTextTab(position, title);//from  w  ww  . j  a va  2  s .  co m
        return;
    }

    TextView tab = new TextView(getContext());
    tab.setText(title);
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    ImageView icon = new ImageView(getContext());
    icon.setImageResource(resId);

    LinearLayout linearLayout = new LinearLayout(getContext());
    linearLayout.setOrientation(LinearLayout.HORIZONTAL);

    linearLayout.addView(icon, defaultTabLayoutParams);
    linearLayout.addView(tab, defaultTabLayoutParams);

    addTab(position, linearLayout);
}

From source file:com.chen.mail.ui.NestedFolderTeaserView.java

/**
 * Creates a {@link FolderHolder}./*from www .  j  a va 2s  .  c om*/
 */
private FolderHolder createFolderHolder(final CharSequence folderName) {
    final View itemView = LayoutInflater.from(getContext()).inflate(R.layout.folder_teaser_item, null);

    final ImageView imageView = (ImageView) itemView.findViewById(R.id.folder_imageView);
    imageView.setImageResource(R.drawable.ic_menu_folders_holo_light);
    // Remove background
    imageView.setBackgroundColor(Color.TRANSPARENT);

    ((TextView) itemView.findViewById(R.id.folder_textView)).setText(folderName);
    final TextView sendersTextView = (TextView) itemView.findViewById(R.id.senders_textView);
    final TextView countTextView = (TextView) itemView.findViewById(R.id.count_textView);
    final FolderHolder holder = new FolderHolder(itemView, sendersTextView, countTextView);

    attachOnClickListener(itemView, holder);

    return holder;
}

From source file:com.example.mego.adas.main.adapter.HelpPageViewerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView = mLayoutInflater.inflate(R.layout.pager_item, container, false);

    int resId = 0;
    //set the help photo with current position
    ImageView imageView = itemView.findViewById(R.id.imageView);
    switch (position) {
    case 0://  w ww .ja va 2s  . com
        resId = R.drawable.help_start;
        break;
    case 1:
        resId = R.drawable.car_help_zero;
        break;
    case 2:
        resId = R.drawable.car_help_one;
        break;
    case 3:
        resId = R.drawable.car_help_two;
        break;
    case 4:
        resId = R.drawable.car_help_three;
        break;
    case 5:
        resId = R.drawable.car_help_four;
        break;
    }
    imageView.setImageResource(resId);

    container.addView(itemView);

    return itemView;
}

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

private void addCmTab(final int position, String title, int resId) {
    RelativeLayout tab = (RelativeLayout) inflate(getContext(), R.layout.cm_pst__tab, null);
    ImageView iv = (ImageView) tab.findViewById(R.id.pst_iv_tab);
    iv.setImageResource(resId);
    iv.setVisibility(View.VISIBLE);
    TextView tv = (TextView) tab.findViewById(R.id.pst_tv_tab);
    tv.setText(title);//from  w  w  w  .  jav a 2s  . c om
    tv.setGravity(Gravity.CENTER);
    tv.setSingleLine();
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);
}