List of usage examples for android.view View setBackgroundDrawable
@Deprecated public void setBackgroundDrawable(Drawable background)
From source file:com.facebook.GraphObjectListFragment.java
private void inflateTitleBar(ViewGroup view) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub); if (stub != null) { View titleBar = stub.inflate(); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); listView.setLayoutParams(layoutParams); if (titleBarBackground != null) { titleBar.setBackgroundDrawable(titleBarBackground); }/*from w w w . j a v a 2s. co m*/ doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button); if (doneButton != null) { doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (onDoneButtonClickedListener != null) { onDoneButtonClickedListener.onDoneButtonClicked(); } } }); if (doneButtonText == null) { doneButtonText = getDefaultDoneButtonText(); } if (doneButtonText != null) { doneButton.setText(doneButtonText); } if (doneButtonBackground != null) { doneButton.setBackgroundDrawable(doneButtonBackground); } } titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleTextView != null) { if (titleText == null) { titleText = getDefaultTitleText(); } if (titleText != null) { titleTextView.setText(titleText); } } } }
From source file:com.mobicage.rogerthat.plugins.friends.ServiceActionMenuActivity.java
private void populateScreen(final ServiceMenu menu) { menuBrandingHash = menu.branding;/*w ww.ja v a2 s . c o m*/ final FriendsPlugin friendsPlugin = mService.getPlugin(FriendsPlugin.class); final MessagingPlugin messagingPlugin = mService.getPlugin(MessagingPlugin.class); final FriendStore store = friendsPlugin.getStore(); List<Cell> usedCells = new ArrayList<Cell>(); if (page == 0) { addAboutHandler(usedCells, menu.aboutLabel); addHistoryHandler(usedCells, store, menu.messagesLabel); addCallHandler(menu, usedCells, menu.callLabel); if (CloudConstants.isYSAAA()) { addScanHandler(menu, usedCells, null); } else { addShareHandler(menu, usedCells, menu.shareLabel); } } boolean[] rows = new boolean[] { false, false, false }; if (page == 0) rows[0] = true; for (final ServiceMenuItem item : menu.itemList) { rows[(int) item.coords[1]] = true; final Cell cell = cells[(int) item.coords[0]][(int) item.coords[1]]; View.OnClickListener onClickListener = new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { pressMenuItem(menu, messagingPlugin, store, item); } }; ((View) cell.icon.getParent()).setOnClickListener(onClickListener); cell.icon.setImageBitmap(BitmapFactory.decodeByteArray(item.icon, 0, item.icon.length)); cell.icon.setVisibility(View.VISIBLE); cell.label.setText(item.label); cell.label.setVisibility(View.VISIBLE); usedCells.add(cell); } for (int i = 2; i >= 0; i--) { if (rows[i]) break; tableRows[i].setVisibility(View.GONE); } boolean showBranded = false; boolean useDarkScheme = false; Integer menuItemColor = null; if (menu.branding != null) { try { BrandingMgr brandingMgr = messagingPlugin.getBrandingMgr(); Friend friend = store.getExistingFriend(email); if (brandingMgr.isBrandingAvailable(menu.branding)) { BrandingResult br = brandingMgr.prepareBranding(menu.branding, friend, false); WebSettings settings = branding.getSettings(); settings.setJavaScriptEnabled(false); settings.setBlockNetworkImage(false); branding.setVisibility(View.VISIBLE); branding.setVerticalScrollBarEnabled(false); final int displayWidth = UIUtils.getDisplayWidth(this); final int calculatedHeight = BrandingMgr.calculateHeight(br, displayWidth); final long start = System.currentTimeMillis(); branding.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { int height = branding.getMeasuredHeight(); if (height > calculatedHeight * 90 / 100 || System.currentTimeMillis() - start > 3000) { if (calculatedHeight > 0) { setBrandingHeight(height); } else { mService.postDelayedOnUIHandler(new SafeRunnable() { @Override protected void safeRun() throws Exception { setBrandingHeight(branding.getMeasuredHeight()); } }, 100); } branding.getViewTreeObserver().removeOnPreDrawListener(this); } return false; } }); branding.loadUrl("file://" + br.file.getAbsolutePath()); if (br.color != null) { branding.setBackgroundColor(br.color); activity.setBackgroundColor(br.color); } if (br.scheme == ColorScheme.dark) { for (Cell cell : usedCells) { cell.label.setTextColor(darkSchemeTextColor); cell.label.setShadowLayer(2, 1, 1, Color.BLACK); } useDarkScheme = true; } menuItemColor = br.menuItemColor; final ImageView watermarkView = (ImageView) findViewById(R.id.watermark); if (br.watermark != null) { BitmapDrawable watermark = new BitmapDrawable(getResources(), BitmapFactory.decodeFile(br.watermark.getAbsolutePath())); watermark.setGravity(Gravity.BOTTOM | Gravity.RIGHT); watermarkView.setImageDrawable(watermark); final LayoutParams layoutParams = watermarkView.getLayoutParams(); layoutParams.width = layoutParams.height = displayWidth; } else { watermarkView.setImageDrawable(null); } showBranded = true; } else { friend.actionMenu = menu; friend.actionMenu.items = menu.itemList.toArray(new ServiceMenuItemTO[] {}); brandingMgr.queue(friend); } } catch (BrandingFailureException e) { L.bug("Could not display service action menu with branding.", e); } } if (!showBranded) { setNavigationBarVisible(AppConstants.SHOW_NAV_HEADER); setNavigationBarTitle(menu.name); title.setVisibility(View.GONE); title.setText(menu.name); } for (final Cell cell : usedCells) { final View p = (View) cell.icon.getParent(); final Drawable d = getResources().getDrawable( useDarkScheme ? R.drawable.mc_smi_background_light : R.drawable.mc_smi_background_dark); p.setBackgroundDrawable(d); } if (menuItemColor == null) menuItemColor = Color.parseColor("#646464"); for (Cell cell : new Cell[] { cells[0][0], cells[1][0], cells[2][0], cells[3][0] }) cell.faIcon.setTextColor(menuItemColor); if (menu.maxPage > 0) { for (int i = 0; i <= menu.maxPage; i++) { ImageView bolleke = (ImageView) getLayoutInflater().inflate(R.layout.page, pages, false); if (page == i) { if (useDarkScheme) { bolleke.setImageResource(R.drawable.current_page_dark); } else { bolleke.setImageResource(R.drawable.current_page_light); } } else { if (useDarkScheme) { bolleke.setImageResource(R.drawable.other_page_dark); } else { bolleke.setImageResource(R.drawable.other_page_light); } } pages.addView(bolleke); } pages.setVisibility(View.VISIBLE); } final int leftPage = page - 1; final int rightPage = page + 1; final String service = email; Slider instance = new Slider(this, this, page == menu.maxPage ? null : new Slider.Swiper() { @Override public Intent onSwipe() { return new Intent(ServiceActionMenuActivity.this, ServiceActionMenuActivity.class) .putExtra(SERVICE_EMAIL, service).putExtra(MENU_PAGE, rightPage); } }, page == 0 ? null : new Slider.Swiper() { @Override public Intent onSwipe() { return new Intent(ServiceActionMenuActivity.this, ServiceActionMenuActivity.class) .putExtra(SERVICE_EMAIL, service).putExtra(MENU_PAGE, leftPage); } }); mGestureScanner = new GestureDetector(this, instance); }
From source file:com.indev.calculator.widget.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null;/*from www. jav a 2s . c o m*/ if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); //Changing of tabs background color tabView.setBackgroundDrawable(getResources().getDrawable(R.drawable.selector_tabs)); tabView.setAlpha(0.9f); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } //Changing of tabs text color and size tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector_tab_text)); tabTitleView.setTextSize(14); } }
From source file:org.gots.ui.NewSeedActivity.java
/** * */// w w w . jav a2 s .c om private void initSpecieList() { // final LocalSeedProvider helper = new LocalSeedProvider(getApplicationContext()); new AsyncTask<Void, Void, String[]>() { @Override protected String[] doInBackground(Void... params) { String[] specieList = seedManager.getArraySpecies(true); return specieList; } @Override protected void onPostExecute(String[] specieList) { // TODO Auto-generated method stub ListSpeciesAdapter listSpeciesAdapter = new ListSpeciesAdapter(getApplicationContext(), specieList, newSeed); gallerySpecies.setAdapter(listSpeciesAdapter); gallerySpecies.setSpacing(5); super.onPostExecute(specieList); } }.execute(); gallerySpecies.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { gallerySpecies.dispatchSetSelected(false); if (((String) view.getTag()).equals(newSeed.getSpecie())) { // clicked already selected item return; } // Selected specie changed -> remove background on others for (int i = 0; i < parent.getChildCount(); i++) { View childView = parent.getChildAt(i); if (childView != view) { childView.setBackgroundColor(0); } } view.setSelected(true); view.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_state_warning)); newSeed.setSpecie((String) view.getTag()); String family = seedManager.getFamilyBySpecie(newSeed.getSpecie()); newSeed.setFamily(family); seedWidgetLong.setSeed(newSeed); seedWidgetLong.invalidate(); } }); }
From source file:com.simplealertdialog.SimpleAlertDialog.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @SuppressWarnings("deprecation") private void setBackground(final View view, final Drawable d) { if (view == null || d == null) { return;/*from w ww . ja v a 2 s. co m*/ } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setBackground(d.getConstantState().newDrawable()); } else { view.setBackgroundDrawable(d.getConstantState().newDrawable()); } }
From source file:com.aniruddhc.acemusic.player.Drawers.InnerNavigationDrawerFragment.java
@SuppressLint("NewApi") @Override//from ww w.j ava2 s. c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.navigation_drawer_layout, null); mApp = (Common) getActivity().getApplicationContext(); browsersListView = (ListView) rootView.findViewById(R.id.browsers_list_view); librariesListView = (ListView) rootView.findViewById(R.id.libraries_list_view); browsersHeaderText = (TextView) rootView.findViewById(R.id.browsers_header_text); librariesHeaderText = (TextView) rootView.findViewById(R.id.libraries_header_text); librariesColorTagImageView = (ImageView) rootView.findViewById(R.id.library_color_tag); librariesIcon = (ImageView) rootView.findViewById(R.id.libraries_icon); librariesIcon.setImageResource(UIElementsHelper.getIcon(getActivity(), "libraries")); Drawable backgroundDrawable; if (mApp.getCurrentTheme() == Common.DARK_THEME) { backgroundDrawable = new ColorDrawable(0x191919); } else { backgroundDrawable = getResources().getDrawable(R.drawable.holo_white_selector); } int currentAPI = android.os.Build.VERSION.SDK_INT; if (currentAPI < android.os.Build.VERSION_CODES.JELLY_BEAN) { rootView.setBackgroundDrawable(backgroundDrawable); } else { rootView.setBackground(backgroundDrawable); } //Set the header text fonts/colors. browsersHeaderText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); librariesHeaderText.setTypeface(TypefaceHelper.getTypeface(getActivity(), "RobotoCondensed-Light")); browsersHeaderText.setPaintFlags(browsersHeaderText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.SUBPIXEL_TEXT_FLAG); librariesHeaderText.setPaintFlags(librariesHeaderText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.FAKE_BOLD_TEXT_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Apply the Browser ListView's adapter. List<String> titles = Arrays .asList(getActivity().getResources().getStringArray(R.array.sliding_menu_array)); NavigationDrawerAdapter slidingMenuAdapter = new NavigationDrawerAdapter(getActivity(), new ArrayList<String>(titles)); browsersListView.setAdapter(slidingMenuAdapter); browsersListView.setOnItemClickListener(browsersClickListener); setListViewHeightBasedOnChildren(browsersListView); /*//Apply the Libraries ListView's adapter. userLibrariesDBHelper = new DBAccessHelper(getActivity().getApplicationContext()); cursor = userLibrariesDBHelper.getAllUniqueLibraries(); NavigationDrawerLibrariesAdapter slidingMenuLibrariesAdapter = new NavigationDrawerLibrariesAdapter(getActivity(), cursor); librariesListView.setAdapter(slidingMenuLibrariesAdapter); setListViewHeightBasedOnChildren(librariesListView);*/ librariesListView.setVisibility(View.GONE); librariesHeaderText.setVisibility(View.GONE); librariesIcon.setVisibility(View.GONE); return rootView; }
From source file:com.c4mprod.utils.ImageManager.java
private ImageManager(final Context ctx) { instance = this; mDowloadLooper = new LooperThread(); mDowloadLooper.start();// www . j a va 2s. c o m mUiHandler = new Handler() { @Override public void handleMessage(Message msg) { if (mStopped) { return; } ImageDownloadMessageData messageData = (ImageDownloadMessageData) msg.obj; View v = messageData.viewRef.get(); if (v != null && messageData.bitmap != null && messageData == getImageDownloadData(v, messageData.flags)) { if (messageData.listerner != null) { messageData.listerner.onImageDownloaded(v, messageData.bitmap); } else { if (v instanceof ImageView) { if ((messageData.flags & FLAG_IN_BACKGROUND) != 0) { BitmapDrawable bd = new BitmapDrawable(ctx.getResources(), messageData.bitmap); v.setBackgroundDrawable(bd); } else { ((ImageView) v).setImageBitmap(messageData.bitmap); } } else if (v instanceof ImageButton) { if ((messageData.flags & FLAG_IN_BACKGROUND) != 0) { BitmapDrawable bd = new BitmapDrawable(ctx.getResources(), messageData.bitmap); v.setBackgroundDrawable(bd); } else { ((ImageButton) v).setImageBitmap(messageData.bitmap); } } else { // no src BitmapDrawable bd = new BitmapDrawable(ctx.getResources(), messageData.bitmap); v.setBackgroundDrawable(bd); } } } }; }; // create cache dir if needed new File(ctx.getExternalCacheDir() + THUMB_FOLDER).mkdirs(); }
From source file:com.initialxy.cordova.themeablebrowser.ThemeableBrowser.java
private void setBackground(View view, Drawable drawable) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { view.setBackgroundDrawable(drawable); } else {/*from w ww. j av a 2 s.co m*/ view.setBackground(drawable); } }
From source file:com.trk.aboutme.facebook.widget.PickerFragment.java
private void inflateTitleBar(ViewGroup view) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub); if (stub != null) { View titleBar = stub.inflate(); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); listView.setLayoutParams(layoutParams); if (titleBarBackground != null) { titleBar.setBackgroundDrawable(titleBarBackground); }//ww w .ja va 2s. c o m doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button); if (doneButton != null) { doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (onDoneButtonClickedListener != null) { onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this); } } }); if (getDoneButtonText() != null) { doneButton.setText(getDoneButtonText()); } if (doneButtonBackground != null) { doneButton.setBackgroundDrawable(doneButtonBackground); } } titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleTextView != null) { if (getTitleText() != null) { titleTextView.setText(getTitleText()); } } } }
From source file:com.eutectoid.dosomething.picker.PickerFragment.java
private void inflateTitleBar(ViewGroup view) { ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub); if (stub != null) { View titleBar = stub.inflate(); final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar); listView.setLayoutParams(layoutParams); if (titleBarBackground != null) { titleBar.setBackgroundDrawable(titleBarBackground); }/*from w w w .j a v a2s .c o m*/ doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button); if (doneButton != null) { doneButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { logAppEvents(true); appEventsLogged = true; if (onDoneButtonClickedListener != null) { onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this); } } }); if (getDoneButtonText() != null) { doneButton.setText(getDoneButtonText()); } if (doneButtonBackground != null) { doneButton.setBackgroundDrawable(doneButtonBackground); } } titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title); if (titleTextView != null) { if (getTitleText() != null) { titleTextView.setText(getTitleText()); } } } }