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:org.odk.collect.android.widgets.SelectMultiWidget.java

@SuppressWarnings("unchecked")
public SelectMultiWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mPrompt = prompt;/*from   w  ww  .  ja  va  2 s  .com*/
    mCheckboxes = new ArrayList<CheckBox>();

    // SurveyCTO-added support for dynamic select content (from .csv files)
    XPathFuncExpr xPathFuncExpr = ExternalDataUtil.getSearchXPathExpression(prompt.getAppearanceHint());
    if (xPathFuncExpr != null) {
        mItems = ExternalDataUtil.populateExternalChoices(prompt, xPathFuncExpr);
    } else {
        mItems = prompt.getSelectChoices();
    }

    setOrientation(LinearLayout.VERTICAL);

    String fieldElementReference = prompt.getFormElement().getBind().getReference().toString();
    fieldName = getFieldID(fieldElementReference);

    if (fieldName.equalsIgnoreCase("typedirt")) {
        if (PropertiesUtils.getiAnswer32() == 1) {
            setVisibility(VISIBLE);
        } else
            setVisibility(INVISIBLE);
        PropertiesUtils.setLayoutQuestion321(this);
    }
    if (fieldName.equalsIgnoreCase("taste1")) {
        if (PropertiesUtils.getiAns33() == 0) {
            setVisibility(INVISIBLE);
        } else {
            if (PropertiesUtils.getiAns332() == 0) {
                setVisibility(INVISIBLE);
            } else
                setVisibility(VISIBLE);
        }
        PropertiesUtils.setLayoutQues333(this);
    }
    Vector<Selection> ve = new Vector<Selection>();
    if (prompt.getAnswerValue() != null) {
        ve = (Vector<Selection>) prompt.getAnswerValue().getValue();
    }

    //       int row_index       = 0 ;
    //       int col_index       = 0 ;
    Boolean isNewRow = false;
    Boolean isAddDirect = false;
    Boolean isTextView = false;
    Boolean isAddDivider = false;
    int itemCount = 0;

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT, 0.5f);
    if (mItems != null) {
        for (int i = 0; i < mItems.size(); i++) {
            // no checkbox group so id by answer + offset
            View c;
            //Check text of the Choice Start With ($), i must be category
            if (prompt.getSelectChoiceText(mItems.get(i)).startsWith("$")) {
                StringBuilder sb = new StringBuilder(prompt.getSelectChoiceText(mItems.get(i)));
                String str = sb.deleteCharAt(0).toString();

                c = new TextView(getContext());
                ((TextView) c).setText(str);
                ((TextView) c).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize + 1);
                ((TextView) c).setTypeface(null, Typeface.BOLD_ITALIC);
                c.setPadding(70, 10, 10, 10);
                c.setId(QuestionWidget.newUniqueId()); // assign random id
                isNewRow = true;
                itemCount = 0;
                isTextView = true;
                mCheckboxes.add(new CheckBox(context));
            } else { //  checkbox 
                isNewRow = true;
                isTextView = false;
                itemCount++;
                c = new CheckBox(getContext());
                c.setTag(Integer.valueOf(i));
                c.setId(QuestionWidget.newUniqueId());
                ((CheckBox) c).setText(prompt.getSelectChoiceText(mItems.get(i)));
                ((CheckBox) c).setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
                c.setFocusable(!prompt.isReadOnly());
                c.setEnabled(!prompt.isReadOnly());
                c.setPadding(10, 10, 10, 10);
                ((CheckBox) c).setLineSpacing(1, 1.15f);
                mCheckboxes.add((CheckBox) c);

            }

            if (!isTextView)
                for (int vi = 0; vi < ve.size(); vi++) {
                    // match based on value, not key
                    if (mItems.get(i).getValue().equals(ve.elementAt(vi).getValue())) {
                        ((CheckBox) c).setChecked(true);
                        break;
                    }

                }

            if (!prompt.getSelectChoiceText(mItems.get(i)).startsWith("$")) {
                // when clicked, check for readonly before toggling

                ((CheckBox) c).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

                        try {
                            if (fieldName.equalsIgnoreCase("typedirt")) {

                                if (mItems.get((Integer) buttonView.getTag()).getValue()
                                        .equalsIgnoreCase("other")) {
                                    if (isChecked) {
                                        PropertiesUtils.getTvQuestion321Other().setVisibility(VISIBLE);
                                        PropertiesUtils.getEdQuestion321Other().setVisibility(VISIBLE);
                                        PropertiesUtils.setiAnswer321(1);
                                        PropertiesUtils.setIsOther321Checked(true);

                                    } else {
                                        PropertiesUtils.getTvQuestion321Other().setVisibility(INVISIBLE);
                                        PropertiesUtils.getEdQuestion321Other().setVisibility(INVISIBLE);
                                        PropertiesUtils.setiAnswer321(0);
                                        PropertiesUtils.setIsOther321Checked(false);
                                    }
                                } else {
                                    PropertiesUtils.getTvQuestion321Other().setVisibility(INVISIBLE);
                                    PropertiesUtils.getEdQuestion321Other().setVisibility(INVISIBLE);
                                    if (PropertiesUtils.isIsOther321Checked() == true) {
                                        PropertiesUtils.getTvQuestion321Other().setVisibility(VISIBLE);
                                        PropertiesUtils.getEdQuestion321Other().setVisibility(VISIBLE);
                                        PropertiesUtils.setiAnswer321(1);
                                    }
                                }

                            }
                            if (fieldName.equalsIgnoreCase("taste1")) {
                                if (mItems.get((Integer) buttonView.getTag()).getValue()
                                        .equalsIgnoreCase("other_taste")) {
                                    if (isChecked) {
                                        PropertiesUtils.setiAns333(1);
                                        PropertiesUtils.getTvQues333Other().setVisibility(VISIBLE);
                                        PropertiesUtils.getEdQues333Other().setVisibility(VISIBLE);
                                        PropertiesUtils.setIsOther333Checked(true);
                                    } else {
                                        PropertiesUtils.setiAns333(0);
                                        PropertiesUtils.getTvQues333Other().setVisibility(INVISIBLE);
                                        PropertiesUtils.getEdQues333Other().setVisibility(INVISIBLE);
                                        PropertiesUtils.setIsOther333Checked(false);
                                    }
                                } else {
                                    PropertiesUtils.getTvQues333Other().setVisibility(INVISIBLE);
                                    PropertiesUtils.getEdQues333Other().setVisibility(INVISIBLE);
                                    if (PropertiesUtils.isIsOther333Checked() == true) {
                                        PropertiesUtils.getTvQues333Other().setVisibility(VISIBLE);
                                        PropertiesUtils.getEdQues333Other().setVisibility(VISIBLE);
                                        PropertiesUtils.setiAns333(1);
                                    }
                                }

                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        if (!mCheckboxInit && mPrompt.isReadOnly()) {
                            if (buttonView.isChecked()) {
                                buttonView.setChecked(false);
                                Collect.getInstance().getActivityLogger().logInstanceAction(this,
                                        "onItemClick.deselect",
                                        mItems.get((Integer) buttonView.getTag()).getValue(),
                                        mPrompt.getIndex());
                            } else {
                                buttonView.setChecked(true);
                                Collect.getInstance().getActivityLogger().logInstanceAction(this,
                                        "onItemClick.select",
                                        mItems.get((Integer) buttonView.getTag()).getValue(),
                                        mPrompt.getIndex());
                            }
                        }
                    }
                });
            }

            String audioURI = null;
            audioURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), FormEntryCaption.TEXT_FORM_AUDIO);

            String imageURI;
            if (mItems.get(i) instanceof ExternalSelectChoice) {
                imageURI = ((ExternalSelectChoice) mItems.get(i)).getImage();
            } else {
                imageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i),
                        FormEntryCaption.TEXT_FORM_IMAGE);
            }

            String videoURI = null;
            videoURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "video");

            String bigImageURI = null;
            bigImageURI = prompt.getSpecialFormSelectChoiceText(mItems.get(i), "big-image");

            MediaLayout mediaLayout = new MediaLayout(getContext());
            if (isTextView) {
                mediaLayout.setAVT(prompt.getIndex(), "." + Integer.toString(i), (TextView) c, audioURI,
                        imageURI, videoURI, bigImageURI);
            } else {
                mediaLayout.setAVT(prompt.getIndex(), "." + Integer.toString(i), (CheckBox) c, audioURI,
                        imageURI, videoURI, bigImageURI);
            }
            mediaLayout.setLayoutParams(params);

            //                row_index = i/2 +1;
            //                col_index = i%2;

            if (itemCount == 2) {
                isNewRow = false;
                itemCount = 0;
            }

            if (isNewRow) {
                ll = null;
                ll = new LinearLayout(getContext());
                ll.setOrientation(LinearLayout.HORIZONTAL);
                ll.addView(mediaLayout);
                isNewRow = false;
                isAddDirect = false;
                isAddDivider = false;

                try {
                    //if textview (category in choices) or the next element is textView , so must add direct
                    if (isTextView || prompt.getSelectChoiceText(mItems.get(i + 1)).startsWith("$"))
                        isAddDirect = true;
                } catch (Exception e) {
                    isAddDirect = true;

                }

                if (isAddDirect) {
                    addView(ll);
                    isAddDivider = true;
                }
            } else {
                ll.addView(mediaLayout);
                addView(ll);
                isAddDivider = true;
            }

            // add the dividing line between elements (except for the last element) but not last
            ImageView divider = new ImageView(getContext());
            divider.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            int size = mItems.size() / 2;
            // if ( (i+1)/2< size && (i+1)%2==0) {
            if (isAddDivider && i < mItems.size() - 1)
                addView(divider);

            // }

        }
    }

    mCheckboxInit = false;

}

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

@Override
public void initView() {
    setSupportActionBar(toolbar);//w ww  . j av  a 2s.com
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    insurerId = bundle.getString("insurerId");
    serialId = bundle.getString("serialId");
    city = bundle.getString("city");
    licenseNo = bundle.getString("licenseNo");
    insureName = bundle.getString("insureName");
    driveName = bundle.getString("driveName");
    idNo = bundle.getString("idNo");
    mobile = bundle.getString("mobile");

    carExtras = bundle.getString("carExtras");
    carPrice = bundle.getString("carPrice");
    modelCode = bundle.getString("modelCode");
    int size = bundle.getInt("size", -1);
    for (int i = 0; i < size; i++) {
        //????
        List<ComCarPropsBean.PlanListBean.SyxListBean> syxList = bundle.getParcelableArrayList("syxList" + i);
        for (int j = 0; j < syxList.size(); j++) {
            List<ComCarPropsBean.PlanListBean.SyxListBean.AmountListBeanXXX> amountList = bundle
                    .getParcelableArrayList("amountList" + i + j);
            syxList.get(j).setAmountList(amountList);
        }
        //????
        List<ComCarPropsBean.PlanListBean.JqxListBean> jqxList = bundle.getParcelableArrayList("jqxList" + i);
        for (int j = 0; j < jqxList.size(); j++) {
            List<ComCarPropsBean.PlanListBean.JqxListBean.AmountListBeanX> amountJqxList = bundle
                    .getParcelableArrayList("amountJqxList" + i + j);
            jqxList.get(j).setAmountList(amountJqxList);
        }
        //????
        List<ComCarPropsBean.PlanListBean.FjxListBean> fjxList = bundle.getParcelableArrayList("fjxList" + i);
        for (int j = 0; j < fjxList.size(); j++) {
            List<ComCarPropsBean.PlanListBean.FjxListBean.AmountListBean> amountFjxList = bundle
                    .getParcelableArrayList("amountFjxList" + i + j);
            fjxList.get(j).setAmountList(amountFjxList);
        }
        //????
        List<ComCarPropsBean.PlanListBean.QtxListBean> qtxList = bundle.getParcelableArrayList("qtxList" + i);
        for (int j = 0; j < qtxList.size(); j++) {
            List<ComCarPropsBean.PlanListBean.QtxListBean.AmountListBeanXX> amountQtxList = bundle
                    .getParcelableArrayList("amountQtxList" + i + j);
            qtxList.get(j).setAmountList(amountQtxList);
        }

        ComCarPropsBean.PlanListBean planListBean = new ComCarPropsBean.PlanListBean();
        //
        planListBean.setSyxList(syxList);
        planListBean.setFjxList(fjxList);
        planListBean.setQtxList(qtxList);
        planListBean.setJqxList(jqxList);
        planList.add(planListBean);
    }

    for (int i = 0; i < planList.size(); i++) {
        /*Item item = new BannerBean();
        mlist.add(item);*/

        ImageView dotView = new ImageView(mContext);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(10, 10);
        lp.leftMargin = 10;
        dotView.setLayoutParams(lp);
        dotView.setBackgroundResource(R.drawable.dot_selected);
        dotList.add(dotView);
        lin_add.addView(dotView);
        if (i == 0) {//---------2
            dotList.get(i).setAlpha(1);
        } else {
            dotList.get(i).setAlpha(0.38f);
        }
    }

    //mCardAdapter = new CardPagerAdapter(this, mlist);
    mCardAdapter = new CardPagerAdapter(this, planList);
    mCardShadowTransformer = new ShadowTransformer(vp_tb, mCardAdapter);
    mCardShadowTransformer.setCanAlpha(true);
    mCardAdapter.setTransformer(mCardShadowTransformer);

    vp_tb.setAdapter(mCardAdapter);
    mCardAdapter.setPager(vp_tb);
    vp_tb.setPageTransformer(false, mCardShadowTransformer);
    mCardShadowTransformer.setAlpha(0.6f, true);
    mCardShadowTransformer.setScale(0.1f, true);

    //vp_tb.setCurrentItem(2);---------------
    //vp_tb.setCurrentItem(10000 / 2 - 10000 / 2 % 3);

    if (planList.size() > 0) {
        vp_tb.setCurrentItem(0);
        getPlanPrice(0);
    }
    vp_tb.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            dotList.get(prePosition).setAlpha(0.38f);
            /*dotList.get(position%3).setAlpha(1);
            prePosition=position%3;*/
            dotList.get(position).setAlpha(1);
            prePosition = position;

            //?
            getPlanPrice(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
}

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 w  w  . j  a va 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);
}

From source file:org.mercycorps.translationcards.activity.RecordingActivity.java

private void moveToDoneStep() {
    setContentView(R.layout.recording_done);
    recycleBitmap();//from  ww  w . j  a v a 2s .c  o m
    currentBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.recording_done_image);
    currentBitmapView = (ImageView) findViewById(R.id.recording_done_image);
    currentBitmapView.setImageBitmap(currentBitmap);
    TextView titleView = (TextView) findViewById(R.id.recording_done_title);
    titleView.setText(getString(R.string.recording_done_title, dictionaryLabel));
    TextView detailView = (TextView) findViewById(R.id.recording_done_detail);
    detailView.setText(getString(R.string.recording_done_detail, dictionaryLabel));
    TextView cardTextView = (TextView) findViewById(R.id.origin_translation_text);
    cardTextView.setText(label);
    TextView translatedCardText = (TextView) findViewById(R.id.translated_text);
    if (translatedText.trim().isEmpty()) {
        translatedCardText.setHint(String.format(getString(R.string.translated_text_hint), dictionaryLabel));
        translatedCardText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    } else {
        translatedCardText.setText(translatedText);
        translatedCardText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    }
    ImageView cardIndicator = (ImageView) findViewById(R.id.indicator_icon);
    cardIndicator.setBackgroundResource(R.drawable.collapse_arrow);
    findViewById(R.id.translation_child).setVisibility(View.VISIBLE);
    findViewById(R.id.translation_child_actions).setVisibility(View.GONE);

    final CardAudioClickListener cardAudioClickListener = new CardAudioClickListener(
            new Dictionary.Translation(label, IS_ASSET, filename, NO_DB_ID, translatedText),
            (ProgressBar) findViewById(R.id.recording_done_progress_bar), mediaPlayerManager);
    findViewById(R.id.recording_done_card).setOnClickListener(cardAudioClickListener);

    View backButton = findViewById(R.id.recording_done_edit);
    backButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cardAudioClickListener.stopMediaPlayer();
            inEditMode = true;
            moveToLabelStep();
        }
    });

    View doneButton = (View) findViewById(R.id.recording_done);
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            recycleBitmap();
            setResult(RESULT_OK, intent);
            finish();
        }
    });
    stepHistory.push(Step.DONE);
}

From source file:com.markupartist.sthlmtraveling.ui.view.SlidingTabLayout.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)}./* ww  w .  j av a2  s  . com*/
 */
protected ImageView createImageTabView(Context context) {
    ImageView v = new ImageView(context);
    v.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);
    v.setBackgroundResource(outValue.resourceId);

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

    return v;
}

From source file:com.mzs.guaji.core.TabPagerActivity.java

/**
 * Create tab using information from current adapter
 * <p>//from w  w  w.j av  a 2  s  .  c  o m
 * This can be called when the tabs changed but must be called after an
 * initial call to {@link #configureTabPager()}
 */
protected void createTabs() {
    if (host.getTabWidget().getTabCount() > 0) {
        // Crash on Gingerbread if tab isn't set to zero since adding a
        // new tab removes selection state on the old tab which will be
        // null unless the current tab index is the same as the first
        // tab index being added
        host.setCurrentTab(0);
        host.clearAllTabs();
    }

    LayoutInflater inflater = getLayoutInflater();
    int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        TabSpec spec = host.newTabSpec("tab" + i);
        spec.setContent(this);
        View view = inflater.inflate(R.layout.tab, null);
        ImageView imageView = (ImageView) view.findViewById(R.id.iv_icon);
        TextView icon = (TextView) view.findViewById(R.id.tv_icon);
        String iconText = getIcon(i);
        if (!TextUtils.isEmpty(iconText))
            icon.setText(getIcon(i));
        else
            ViewUtils.setGone(icon, true);
        //            TypefaceUtils.setOcticons(icon);
        int tabIcon = getTabIcon(i);
        if (tabIcon != 0) {
            imageView.setBackgroundResource(tabIcon);
        } else {
            ViewUtils.setGone(imageView, true);
        }
        ((TextView) view.findViewById(R.id.tv_tab)).setText(getTitle(i));

        spec.setIndicator(view);
        host.addTab(spec);

        int background;
        if (i == 0)
            background = getLeftBackground();
        else if (i == count - 1)
            background = getCentreBackground();
        else
            background = getRightBackground();
        ((ImageView) view.findViewById(R.id.iv_tab)).setImageResource(background);
    }
}

From source file:com.binomed.showtime.android.screen.movie.CineShowTimeMovieFragment.java

private void createTabs(View mainView) {
    try {/*from w  w w.j a  v a2  s  .  com*/
        tabHost = (TabHost) mainView.findViewById(android.R.id.tabhost);
        tabWidget = (TabWidget) mainView.findViewById(android.R.id.tabs);
        // tabHost = getTabHost();
        // tabWidget = getTabWidget();
        tabHost.setup();
        tabHost.getTabWidget().setDividerDrawable(R.drawable.cst_tab_divider);

        Intent intentEmptyActivity = new Intent(interaction.getMainContext(), EmptyActivity.class);

        // TextView txt = new TextView(getActivity());
        // txt.setCompoundDrawables(left, top, right, bottom);
        // txt.setBackgroundResource(resid);
        TabHost.TabSpec tabSummary = tabHost.newTabSpec("Summary");
        // tabSummary.setContent(intentEmptyActivity);
        tabSummary.setContent(new TabHost.TabContentFactory() {

            @Override
            public View createTabContent(String arg0) {
                TextView view = new TextView(interaction.getMainContext());
                return view;
            }
        });
        View viewInfo = LayoutInflater.from(interaction.getMainContext()).inflate(R.layout.view_tab_item, null);
        TextView tvInfo = (TextView) viewInfo.findViewById(R.id.title);
        tvInfo.setText(R.string.movieLabel);
        ImageView ivInfo = (ImageView) viewInfo.findViewById(R.id.icon);
        ivInfo.setBackgroundResource(R.drawable.ic_tab_info);
        tabSummary.setIndicator(viewInfo);
        // tabSummary.setIndicator(getResources().getString(R.string.movieLabel).toUpperCase(), getResources().getDrawable(R.drawable.ic_tab_info));

        TabHost.TabSpec tabProjection = tabHost.newTabSpec("Projection");
        // tabProjection.setContent(intentEmptyActivity);
        tabProjection.setContent(new TabHost.TabContentFactory() {

            @Override
            public View createTabContent(String arg0) {
                TextView view = new TextView(interaction.getMainContext());
                return view;
            }
        });
        View viewShowTimes = LayoutInflater.from(interaction.getMainContext()).inflate(R.layout.view_tab_item,
                null);
        TextView tvShowTimes = (TextView) viewShowTimes.findViewById(R.id.title);
        tvShowTimes.setText(R.string.showtimeLabel);
        ImageView ivShowTimes = (ImageView) viewShowTimes.findViewById(R.id.icon);
        ivShowTimes.setBackgroundResource(R.drawable.ic_tab_showtimes);
        tabProjection.setIndicator(viewShowTimes);
        // tabProjection.setIndicator(getResources().getString(R.string.showtimeLabel).toUpperCase(), getResources().getDrawable(R.drawable.ic_tab_showtimes));

        TabHost.TabSpec tabReviews = tabHost.newTabSpec("Review");
        // tabReviews.setContent(intentEmptyActivity);
        tabReviews.setContent(new TabHost.TabContentFactory() {

            @Override
            public View createTabContent(String arg0) {
                TextView view = new TextView(interaction.getMainContext());
                return view;
            }
        });
        View viewReviews = LayoutInflater.from(interaction.getMainContext()).inflate(R.layout.view_tab_item,
                null);
        TextView tvReviews = (TextView) viewReviews.findViewById(R.id.title);
        tvReviews.setText(R.string.rateLabel);
        ImageView ivReviews = (ImageView) viewReviews.findViewById(R.id.icon);
        ivReviews.setBackgroundResource(R.drawable.ic_tab_review);
        tabReviews.setIndicator(viewReviews);
        // tabReviews.setIndicator(getResources().getString(R.string.rateLabel).toUpperCase(), getResources().getDrawable(R.drawable.ic_tab_review));

        tabHost.addTab(tabSummary);
        tabHost.addTab(tabProjection);
        tabHost.addTab(tabReviews);
        // tabHost.setCurrentTab(model.getLastTab());
    } catch (Exception e1) {
        Log.e(TAG, "error while init Movie acitivty", e1); //$NON-NLS-1$
    }
}

From source file:com.app.jdy.activity.GoldActivity.java

private void resetOrder(LinearLayout v) {
    productList.clear();/* w  ww . jav a  2s  .c  o  m*/
    for (LinearLayout layout : orderLayouts) {
        String layoutId = getResources().getResourceEntryName(layout.getId());
        // ,peroid
        String key = layoutId.split("_")[1];
        //TextView tv = (TextView) findViewByType(layout, 1);
        ImageView iv = (ImageView) findViewByType(layout, 2);
        View split = findViewById(CommonUtils.getIdFromStr(mContext, "view_" + key));
        if (layout != v) {
            iv.setBackgroundResource(R.drawable.up_arrow);
            // ????
            split.setVisibility(View.INVISIBLE);
        } else {
            if (search_orderby == null) {
                search_order = "desc";
                iv.setBackgroundResource(R.drawable.down_arrow);
            } else if (search_orderby.equals(key)) {
                if ("desc".equals(search_order)) {
                    // ???,?
                    search_order = "asc";
                    iv.setBackgroundResource(R.drawable.up_arrow);
                } else if ("asc".equals(search_order) || search_order == null) {
                    // ???,?
                    search_order = "desc";
                    iv.setBackgroundResource(R.drawable.down_arrow);
                }
            } else {
                search_order = "desc";
                iv.setBackgroundResource(R.drawable.down_arrow);
            }
            // ??
            search_orderby = key;
            // ???
            split.setVisibility(View.VISIBLE);
        }
    }
}

From source file:com.cloverstudio.spika.utils.BitmapManager.java

public void loadBitmap(final String url, final ImageView imageView, ProgressBar pbLoading) {
    imageViews.put(imageView, url);//  w ww .  ja va  2  s  . com
    Bitmap bitmap = getBitmapFromCache(url);

    // check in UI thread, so no concurrency issues
    if (bitmap != null) {
        if (smallImg) {
            imageView.setScaleType(ImageView.ScaleType.CENTER);
        } else {
            imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        }
        imageView.setImageBitmap(bitmap);
        if (pbLoading != null)
            pbLoading.setVisibility(View.GONE);
    } else {
        imageView.setImageBitmap(null);
        imageView.setBackgroundResource(R.color.loading_background);
        queueJob(url, imageView, pbLoading);
    }
}

From source file:example.example.com.sportsofficial.presentation.views.ViewTabs.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, int)}.
 *///from www.j av  a 2 s. c o  m
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);
    }

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

    return tabIconImageView;
}