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.ayuget.redface.ui.activity.BaseDrawerActivity.java

private View makeNavDrawerItem(final DrawerItem drawerItem, ViewGroup container) {
    int layoutToInflate = drawerItem.isSeparator() ? R.layout.navigation_drawer_separator
            : R.layout.navigation_drawer_item;

    View view = getLayoutInflater().inflate(layoutToInflate, container, false);

    if (drawerItem.isSeparator()) {
        // Done !
        return view;
    } else {/*from  w ww . j  ava 2  s .c o m*/
        TextView titleView = (TextView) view.findViewById(R.id.item_name);
        ImageView iconView = (ImageView) view.findViewById(R.id.item_icon);

        if (drawerItem.isSimpleItem()) {
            SimpleDrawerItem simpleDrawerItem = (SimpleDrawerItem) drawerItem;
            iconView.setImageResource(simpleDrawerItem.getIconResource());
            titleView.setText(getText(simpleDrawerItem.getTitleResource()));
        } else {
            CategoryDrawerItem categoryDrawerItem = (CategoryDrawerItem) drawerItem;
            iconView.setImageResource(categoryDrawerItem.getIconResource());
            titleView.setText(categoryDrawerItem.getCategory().getName());
        }
    }

    styleNavDrawerItem(view, drawerItem, false);

    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onNavDrawerItemClicked(drawerItem);
        }
    });

    return view;
}

From source file:com.he5ed.lib.cloudprovider.picker.PickerFragment.java

/**
 * Notify user the empty view is due to various causes
 *
 * @param cause of empty, whether empty folder, error or search no result
 * @param error message to be shown, optional only applicable for error cause
 *///from  www. j av  a2 s . c om
private void updateEmptyView(int cause, String error) {
    // find ui items
    ImageView icon = (ImageView) mEmptyView.findViewById(R.id.empty_icon_image_view);
    TextView title = (TextView) mEmptyView.findViewById(R.id.empty_title_text_view);
    TextView detail = (TextView) mEmptyView.findViewById(R.id.empty_detail_text_view);

    switch (cause) {
    case CAUSE_EMPTY:
        icon.setImageResource(R.drawable.ic_folder_open_black_48dp);
        title.setText(R.string.folder_empty_title);
        detail.setText(R.string.folder_empty_detail);
        break;
    case CAUSE_ERROR:
        icon.setImageResource(R.drawable.ic_report_problem_black_48dp);
        title.setText(R.string.error_empty_title);
        detail.setText(error);
        break;
    case CAUSE_SEARCH:
        icon.setImageResource(R.drawable.ic_search_black_48dp);
        title.setText(R.string.search_empty_title);
        detail.setText(R.string.search_empty_detail);
        break;
    }
}

From source file:com.android.deskclock.stopwatch.StopwatchFragment.java

@Override
public void onUpdateFab(@NonNull ImageView fab) {
    if (getStopwatch().isRunning()) {
        fab.setImageResource(R.drawable.ic_pause_white_24dp);
        fab.setContentDescription(fab.getResources().getString(R.string.sw_pause_button));
    } else {/*w  w  w .ja v  a  2 s. co  m*/
        fab.setImageResource(R.drawable.ic_start_white_24dp);
        fab.setContentDescription(fab.getResources().getString(R.string.sw_start_button));
    }
    fab.setVisibility(VISIBLE);
}

From source file:com.materialdesign.view.tab.VerticalTabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {

        View tabView = createDefaultTabView(getContext());

        TextView tabText = (TextView) tabView.findViewById(R.id.tv_tabText);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        if (mTabs.size() > i) {
            Tab tab = mTabs.get(i);/*from   w w w .ja  v a 2s  . c  o  m*/
            if (tab.icon != 0) {
                tabIcon.setImageResource(tab.icon);
            } else {
                tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextMediumSize);
                int padding = (int) (mTabViewCustomPadding * getResources().getDisplayMetrics().density);
                tabView.setPadding(0, padding, 0, padding);
            }

            if (tab.tabText != null) {
                tabText.setText(tab.tabText);
            }
        }

        tabText.setTextColor(mTabTextColorStateList);

        if (mTabViewTextCustomSize != 0) {
            tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextCustomSize);
        }

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 0, 1);
        if (i == 0) {
            tabText.setSelected(true);
            tabIcon.setSelected(true);
        }
        mTabStrip.addView(tabView, lp);
    }

    if (hasMiddleTabView) {
        View tabView = LayoutInflater.from(getContext()).inflate(R.layout.tab_layout, null);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        TextView textView = (TextView) tabView.findViewById(R.id.tv_tabText);

        textView.setVisibility(GONE);

        LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(
                (int) (36 * getResources().getDisplayMetrics().density),
                (int) (36 * getResources().getDisplayMetrics().density));
        tabIcon.setLayoutParams(iconParams);
        tabIcon.setImageResource(mMiddleIconResId);

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT,
                1);

        mTabStrip.addView(tabView, 2, lp);
    }
}

From source file:com.owncloud.android.ui.adapter.FileListListAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    View view = convertView;//from   w w w  . j ava  2 s. c om
    if (view == null) {
        LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflator.inflate(R.layout.list_item, null);
    }

    if (mFiles != null && mFiles.size() > position) {
        OCFile file = mFiles.get(position);
        TextView fileName = (TextView) view.findViewById(R.id.Filename);
        String name = file.getFileName();
        if (dataSourceShareFile == null)
            dataSourceShareFile = new DbShareFile(mContext);

        Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
        String[] accountNames = account.name.split("@");

        if (accountNames.length > 2) {
            accountName = accountNames[0] + "@" + accountNames[1];
            url = accountNames[2];
        }
        Map<String, String> fileSharers = dataSourceShareFile.getUsersWhoSharedFilesWithMe(accountName);
        TextView sharer = (TextView) view.findViewById(R.id.sharer);
        ImageView shareButton = (ImageView) view.findViewById(R.id.shareItem);
        fileName.setText(name);
        ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);
        fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));
        ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
        FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
        FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
        if (fileSharers.size() != 0 && (!file.equals("Shared") && file.getRemotePath().contains("Shared"))) {
            if (fileSharers.containsKey(name)) {
                sharer.setText(fileSharers.get(name));
                fileSharers.remove(name);
            } else {
                sharer.setText(" ");
            }
        } else {
            sharer.setText(" ");
        }

        if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.downloading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
            localStateView.setImageResource(R.drawable.uploading_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else if (file.isDown()) {
            localStateView.setImageResource(R.drawable.local_file_indicator);
            localStateView.setVisibility(View.VISIBLE);
        } else {
            localStateView.setVisibility(View.INVISIBLE);
        }

        TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
        TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
        ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
        shareButton.setOnClickListener(new OnClickListener() {
            String shareStatusDisplay;
            int flagShare = 0;

            @Override
            public void onClick(View v) {
                final Dialog dialog = new Dialog(mContext);
                final OCFile fileToBeShared = (OCFile) getItem(position);
                final ArrayAdapter<String> shareWithFriends;
                final ArrayAdapter<String> shareAdapter;
                final String filePath;
                sharedWith = new ArrayList<String>();
                dataSource = new DbFriends(mContext);
                dataSourceShareFile = new DbShareFile(mContext);
                dialog.setContentView(R.layout.share_file_with);
                dialog.setTitle("Share");
                Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
                String[] accountNames = account.name.split("@");

                if (accountNames.length > 2) {
                    accountName = accountNames[0] + "@" + accountNames[1];
                    url = accountNames[2];
                }

                final AutoCompleteTextView textView = (AutoCompleteTextView) dialog
                        .findViewById(R.id.autocompleteshare);
                Button shareBtn = (Button) dialog.findViewById(R.id.ShareBtn);
                Button doneBtn = (Button) dialog.findViewById(R.id.ShareDoneBtn);
                final ListView listview = (ListView) dialog.findViewById(R.id.alreadySharedWithList);

                textView.setThreshold(2);
                final String itemType;

                filePath = "files" + String.valueOf(fileToBeShared.getRemotePath());
                final String fileName = fileToBeShared.getFileName();
                final String fileRemotePath = fileToBeShared.getRemotePath();
                if (dataSourceShareFile == null)
                    dataSourceShareFile = new DbShareFile(mContext);
                sharedWith = dataSourceShareFile.getUsersWithWhomIhaveSharedFile(fileName, fileRemotePath,
                        accountName, String.valueOf(1));
                shareAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        sharedWith);
                listview.setAdapter(shareAdapter);
                final String itemSource;
                if (fileToBeShared.isDirectory()) {
                    itemType = "folder";
                    int lastSlashInFolderPath = filePath.lastIndexOf('/');
                    itemSource = filePath.substring(0, lastSlashInFolderPath);
                } else {
                    itemType = "file";
                    itemSource = filePath;
                }

                //Permissions disabled with friends app
                ArrayList<String> friendList = dataSource.getFriendList(accountName);
                dataSource.close();
                shareWithFriends = new ArrayAdapter<String>(mContext, android.R.layout.simple_list_item_1,
                        friendList);
                textView.setAdapter(shareWithFriends);
                textView.setFocusableInTouchMode(true);
                dialog.show();
                textView.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

                    }
                });
                final Handler finishedHandler = new Handler() {
                    @Override
                    public void handleMessage(Message msg) {
                        shareAdapter.notifyDataSetChanged();
                        Toast.makeText(mContext, shareStatusDisplay, Toast.LENGTH_SHORT).show();

                    }
                };
                shareBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        final String shareWith = textView.getText().toString();

                        if (shareWith.equals("")) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext,
                                    "Please enter the friends name with whom you want to share",
                                    Toast.LENGTH_SHORT).show();
                        } else if (sharedWith.contains(shareWith)) {
                            textView.setHint("Share With");
                            Toast.makeText(mContext, "You have shared the file with that person",
                                    Toast.LENGTH_SHORT).show();
                        } else {

                            textView.setText("");
                            Runnable runnable = new Runnable() {
                                @Override
                                public void run() {
                                    HttpPost post = new HttpPost(
                                            "http://" + url + "/owncloud/androidshare.php");
                                    final ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();

                                    params.add(new BasicNameValuePair("itemType", itemType));
                                    params.add(new BasicNameValuePair("itemSource", itemSource));
                                    params.add(new BasicNameValuePair("shareType", shareType));
                                    params.add(new BasicNameValuePair("shareWith", shareWith));
                                    params.add(new BasicNameValuePair("permission", permissions));
                                    params.add(new BasicNameValuePair("uidOwner", accountName));
                                    HttpEntity entity;
                                    String shareSuccess = "false";
                                    try {
                                        entity = new UrlEncodedFormEntity(params, "utf-8");
                                        HttpClient client = new DefaultHttpClient();
                                        post.setEntity(entity);
                                        HttpResponse response = client.execute(post);

                                        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                                            HttpEntity entityresponse = response.getEntity();
                                            String jsonentity = EntityUtils.toString(entityresponse);
                                            JSONObject obj = new JSONObject(jsonentity);
                                            shareSuccess = obj.getString("SHARE_STATUS");
                                            flagShare = 1;
                                            if (shareSuccess.equals("true")) {
                                                dataSourceShareFile.putNewShares(fileName, fileRemotePath,
                                                        accountName, shareWith);
                                                sharedWith.add(shareWith);
                                                shareStatusDisplay = "File share succeeded";
                                            } else if (shareSuccess.equals("INVALID_FILE")) {
                                                shareStatusDisplay = "File you are trying to share does not exist";
                                            } else if (shareSuccess.equals("INVALID_SHARETYPE")) {
                                                shareStatusDisplay = "File Share type is invalid";
                                            } else {
                                                shareStatusDisplay = "Share did not succeed. Please check your internet connection";
                                            }

                                            finishedHandler.sendEmptyMessage(flagShare);

                                        }
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }

                                }
                            };
                            new Thread(runnable).start();

                        }

                        if (flagShare == 1) {
                        }

                    }

                });
                doneBtn.setOnClickListener(new OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                        //dataSourceShareFile.close();
                    }
                });
            }

        });
        //dataSourceShareFile.close();
        if (!file.isDirectory()) {
            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            // this if-else is needed even thoe fav icon is visible by default
            // because android reuses views in listview
            if (!file.keepInSync()) {
                view.findViewById(R.id.imageView3).setVisibility(View.GONE);
            } else {
                view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
            }

            ListView parentList = (ListView) parent;
            if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) {
                checkBoxV.setVisibility(View.GONE);
            } else {
                if (parentList.isItemChecked(position)) {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
                } else {
                    checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
                }
                checkBoxV.setVisibility(View.VISIBLE);
            }

        } else {

            fileSizeV.setVisibility(View.VISIBLE);
            fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
            lastModV.setVisibility(View.VISIBLE);
            lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
            checkBoxV.setVisibility(View.GONE);
            view.findViewById(R.id.imageView3).setVisibility(View.GONE);
        }
    }

    return view;
}

From source file:com.materialdesign.view.tab.TabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {

        View tabView = createDefaultTabView(getContext());

        TextView tabText = (TextView) tabView.findViewById(R.id.tv_tabText);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        if (mTabs.size() > i) {
            Tab tab = mTabs.get(i);/* ww  w . j a v a 2s  .  c  o m*/
            if (tab.icon != 0) {
                tabIcon.setImageResource(tab.icon);
            } else {
                tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextMediumSize);
                int padding = (int) (mTabViewCustomPadding * getResources().getDisplayMetrics().density);
                tabView.setPadding(0, padding, 0, padding);
            }

            if (tab.tabText != null) {
                tabText.setText(tab.tabText);
            }
        }

        tabText.setTextColor(mTabTextColorStateList);

        if (mTabViewTextCustomSize != 0) {
            tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextCustomSize);
        }

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT,
                1);
        if (i == 0) {
            tabText.setSelected(true);
            tabIcon.setSelected(true);
        }
        mTabStrip.addView(tabView, lp);
    }

    //tab,tab-?
    if (hasMiddleTabView) {
        View tabView = LayoutInflater.from(getContext()).inflate(R.layout.tab_layout, null);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        TextView textView = (TextView) tabView.findViewById(R.id.tv_tabText);

        textView.setVisibility(GONE);

        LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(
                (int) (36 * getResources().getDisplayMetrics().density),
                (int) (36 * getResources().getDisplayMetrics().density));
        tabIcon.setLayoutParams(iconParams);
        tabIcon.setImageResource(mMiddleIconResId);

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT,
                1);

        mTabStrip.addView(tabView, 2, lp);
    }
}

From source file:com.odt.kandani.View.IntroActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_TMessages);/*from   w w  w  . j  a  va  2  s .  co m*/
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_layout);

    icons = new int[] { R.drawable.intro1, R.drawable.intro2, R.drawable.intro3, R.drawable.intro4 };
    titles = new int[] { R.string.Page1Title, R.string.Page2Title, R.string.Page3Title, R.string.Page4Title };
    messages = new int[] { R.string.Page1Message, R.string.Page2Message, R.string.Page3Message,
            R.string.Page4Message };

    viewPager = (ViewPager) findViewById(R.id.intro_view_pager);
    TextView startMessagingButton = (TextView) findViewById(R.id.start_messaging_button);
    topImage1 = (ImageView) findViewById(R.id.icon_image1);
    topImage2 = (ImageView) findViewById(R.id.icon_image2);
    bottomPages = (ViewGroup) findViewById(R.id.bottom_pages);
    topImage2.setVisibility(View.GONE);
    viewPager.setAdapter(new IntroAdapter());
    viewPager.setPageMargin(0);
    viewPager.setOffscreenPageLimit(1);
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int i) {

        }

        @Override
        public void onPageScrollStateChanged(int i) {
            if (i == ViewPager.SCROLL_STATE_IDLE || i == ViewPager.SCROLL_STATE_SETTLING) {
                if (lastPage != viewPager.getCurrentItem()) {
                    lastPage = viewPager.getCurrentItem();

                    final ImageView fadeoutImage;
                    final ImageView fadeinImage;
                    if (topImage1.getVisibility() == View.VISIBLE) {
                        fadeoutImage = topImage1;
                        fadeinImage = topImage2;

                    } else {
                        fadeoutImage = topImage2;
                        fadeinImage = topImage1;
                    }

                    fadeinImage.bringToFront();
                    fadeinImage.setImageResource(icons[lastPage]);
                    fadeinImage.clearAnimation();
                    fadeoutImage.clearAnimation();

                    Animation outAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_out);
                    outAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            fadeoutImage.setVisibility(View.GONE);
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    Animation inAnimation = AnimationUtils.loadAnimation(IntroActivity.this,
                            R.anim.icon_anim_fade_in);
                    inAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                            fadeinImage.setVisibility(View.VISIBLE);
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });

                    fadeoutImage.startAnimation(outAnimation);
                    fadeinImage.startAnimation(inAnimation);
                }
            }
        }
    });

    startMessagingButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(IntroActivity.this, MainActivity.class);
            IntroActivity.this.startActivity(intent);
            overridePendingTransition(R.anim.pull_in_right, R.anim.push_out_left);
            IntroActivity.this.finish();
        }
    });

    justCreated = true;
}

From source file:com.jana.android.ui.fragment.AbstractMapFragment.java

protected void loadMarkerImage(MapModel model, Marker marker) {

    if (mMarkerViewMap == null) {

        Logger.e("Failed to load marker model image due to the hashmap is not initialized");

        return;//from w ww  .  j  av  a2  s.  c om
    }

    View view = mInflater.inflate(R.layout.popup_map_info_window, null, false);

    final ImageView imageView = (ImageView) view.findViewById(R.id.img_thumbnail);

    String url;

    if (model.getThumbnail() != null) {

        url = model.getThumbnail();

        mImageLoader.displayImage(url, imageView, mOptions);

    } else {

        imageView.setImageResource(R.mipmap.ic_launcher);
    }

    mMarkerViewMap.put(marker, imageView);
}

From source file:com.oneteam.framework.android.ui.impl.fragment.AbstractMapFragment.java

protected void loadMarkerImage(MapModel model, Marker marker) {

    if (mMarkerViewMap == null) {

        Logger.e("Failed to load marker model image due to the hashmap is not initialized");

        return;/*from   ww  w.java2 s . c o  m*/
    }

    View view = mInflater.inflate(R.layout.popup_map_info_window, null, false);

    final ImageView imageView = (ImageView) view.findViewById(R.id.img_thumbnail);

    String url;

    if (model.getThumbnail() != null) {

        url = model.getThumbnail();

        mImageLoader.displayImage(url, imageView, mOptions);

    } else {

        imageView.setImageResource(R.drawable.ic_launcher);
    }

    mMarkerViewMap.put(marker, imageView);
}

From source file:com.android.camera.v2.uimanager.SettingManager.java

private void initializeSettings() {
    if (mSettingLayout == null) {
        mSettingLayout = (ViewGroup) mActivity.getLayoutInflater().inflate(R.layout.setting_container_v2,
                mSettingViewLayer, false);
        mTabHost = (TabHost) mSettingLayout.findViewById(R.id.tab_title);
        mTabHost.setup();/*from w  ww  .  jav  a 2  s  . c  o  m*/
        String action = mIntent.getAction();
        LogHelper.i(TAG, "intent.action:" + action);
        List<Holder> list = new ArrayList<Holder>();
        // default setting
        int commonKeys[] = SettingKeys.SETTING_GROUP_COMMON_FOR_TAB;
        int cameraKeys[] = SettingKeys.SETTING_GROUP_CAMERA_FOR_TAB;
        int videoKeys[] = SettingKeys.SETTING_GROUP_VIDEO_FOR_TAB;

        if (FeatureSwitcher.isSubSettingEnabled()) {
            // For tablet
            commonKeys = SettingKeys.SETTING_GROUP_MAIN_COMMON_FOR_TAB;
        } else if (FeatureSwitcher.isLomoEffectEnabled()) {
            commonKeys = SettingKeys.SETTING_GROUP_COMMON_FOR_LOMOEFFECT;
        }
        // image capture setting, compared to default setting,
        // common settings and video setting may be different.
        if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)) {
            videoKeys = null;
        }
        // image capture setting, compared to default setting,
        // common settings and video setting
        // may be different.
        if (MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
            cameraKeys = null;
        }

        if (commonKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_COMMON, R.drawable.ic_tab_common_setting, commonKeys));
        }
        if (cameraKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_CAMERA, R.drawable.ic_tab_camera_setting, cameraKeys));
        }
        if (videoKeys != null) {
            list.add(new Holder(TAB_INDICATOR_KEY_VIDEO, R.drawable.ic_tab_video_setting, videoKeys));
        }

        int size = list.size();
        List<SettingListLayout> pageViews = new ArrayList<SettingListLayout>();
        for (int i = 0; i < size; i++) {
            Holder holder = list.get(i);
            // new page view
            SettingListLayout pageView = (SettingListLayout) mActivity.getLayoutInflater()
                    .inflate(R.layout.setting_list_layout_v2, mSettingViewLayer, false);
            ArrayList<ListPreference> listItems = new ArrayList<ListPreference>();
            pageView.setRootView(mSettingViewLayer);
            pageView.initialize(getListPreferences(holder.mSettingKeys, i == 0));
            pageView.setSettingChangedListener(SettingManager.this);
            pageViews.add(pageView);
            // new indicator view
            ImageView indicatorView = new ImageView(mActivity);
            if (indicatorView != null) {
                indicatorView.setBackgroundResource(R.drawable.bg_tab_title);
                indicatorView.setImageResource(holder.mIndicatorIconRes);
                indicatorView.setScaleType(ScaleType.CENTER);
            }
            mTabHost.addTab(mTabHost.newTabSpec(holder.mIndicatorKey).setIndicator(indicatorView)
                    .setContent(android.R.id.tabcontent));
        }

        mAdapter = new MyPagerAdapter(pageViews);
        mPager = (ViewPager) mSettingLayout.findViewById(R.id.pager);
        mPager.setAdapter(mAdapter);
        mPager.setOnPageChangeListener(mAdapter);
        mTabHost.setOnTabChangedListener(this);
    }
    int orientation = (Integer) mSettingViewLayer.getTag();
    CameraUtil.setOrientation(mSettingLayout, orientation, false);
}