List of usage examples for android.widget ImageView setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:com.android.fastlibrary.ui.activity.FastWelcomeActivity.java
@Override protected void initData() { ArrayList<View> views = new ArrayList<View>(); int[] images = getWelcomeImages(); indicators = new ImageView[images.length]; for (int i = 0; i < images.length; i++) { // //from w ww . j a va 2 s. c o m ImageView imageView = new ImageView(context); imageView.setBackgroundResource(images[i]); views.add(imageView); // indicators[i] = new ImageView(context); indicators[i].setBackgroundResource(R.drawable.indicators_default); if (i == 0) { indicators[i].setBackgroundResource(R.drawable.indicators_now); } indicatorLayout.addView(indicators[i]); } PagerAdapter pagerAdapter = new WelcomePagerAdapter(views); viewPager.setAdapter(pagerAdapter); // ? viewPager.setOnPageChangeListener(this); }
From source file:com.plnyyanks.frcnotebook.activities.ViewMatch.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(PreferenceHandler.getTheme()); super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_match); activity = this; ActionBar bar = getActionBar();/*from www .j av a 2 s. com*/ bar.setTitle(parentEvent.getEventName() + " - " + parentEvent.getEventYear()); bar.setSubtitle(eventKey); bar.setDisplayHomeAsUpEnabled(true); if (matchKey == null) return; if (PreferenceHandler.getTheme() == R.style.theme_dark) { ImageView nextMatch = (ImageView) findViewById(R.id.next_match); nextMatch.setBackgroundResource(R.drawable.ic_action_next_item_dark); ImageView prevMatch = (ImageView) findViewById(R.id.prev_match); prevMatch.setBackgroundResource(R.drawable.ic_action_previous_item_dark); } new GetNotesForMatch(this).execute(previousKey, matchKey, nextKey, eventKey); if (PreferenceHandler.getFMEnabled()) { TextView fieldMonitor = (TextView) findViewById(R.id.field_monitor_link); fieldMonitor.setVisibility(View.VISIBLE); fieldMonitor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(activity, FieldMonitorActivity.class); startActivity(intent); } }); } }
From source file:org.exoplatform.ui.DashboardActivity.java
private void initStubView() { empty_stub = ((ViewStub) findViewById(R.id.dashboard_empty_stub)).inflate(); ImageView emptyImage = (ImageView) empty_stub.findViewById(R.id.empty_image); emptyImage.setBackgroundResource(R.drawable.icon_for_no_gadgets); TextView emptyStatus = (TextView) empty_stub.findViewById(R.id.empty_status); emptyStatus.setText(dashboardEmptyString); }
From source file:com.coincollection.ReorderAdapter.java
@Override public void onBindViewHolder(final ReorderViewHolder holder, int position) { // TODO Copied from the adapter that handles mainActivity, refactor it // so that this code only lives in one place CollectionListInfo item = mItems.get(position); String tableName = item.getName(); int total = item.getCollected(); if (tableName != null) { //Get the image ImageView image = (ImageView) holder.view.findViewById(R.id.imageView1); if (image != null) { image.setBackgroundResource(item.getCoinImageIdentifier()); }//from ww w . j a v a 2 s . c om TextView tt = (TextView) holder.view.findViewById(R.id.textView1); if (tt != null) { tt.setText(tableName); } TextView mt = (TextView) holder.view.findViewById(R.id.textView2); if (mt != null) { mt.setText(total + "/" + item.getMax()); } TextView bt = (TextView) holder.view.findViewById(R.id.textView3); if (total >= item.getMax()) { // The collection is complete if (bt != null) { bt.setText("Collection Complete!"); } } else { bt.setText(""); } // Start a drag whenever the handle view is touched image.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { mDragStartListener.onStartDrag(holder); } return false; } }); } }
From source file:gidaibero.android.matsol.MatrixDisplayActivity.java
private TableRow decorateTableRow(TableRow tableRow, int height, int width, int row) { ImageView leftImageView = new ImageView(this); ImageView rightImageView = new ImageView(this); leftImageView.setBackgroundResource(R.drawable.left_edge); rightImageView.setBackgroundResource(R.drawable.right_edge); if (target == R.id.matrix_button) { // we need to allocate two more elements ImageView insideLeftImageView = new ImageView(this); ImageView insideRightImageView = new ImageView(this); if (row == 0) { // should change decorators for top decorators leftImageView.setBackgroundResource(R.drawable.top_left_edge); rightImageView.setBackgroundResource(R.drawable.top_right_edge); insideLeftImageView.setBackgroundResource(R.drawable.top_right_edge); // this is not a mistake insideRightImageView.setBackgroundResource(R.drawable.top_left_edge); } else if (row == this.height - 1) { leftImageView.setBackgroundResource(R.drawable.bottom_left_edge); rightImageView.setBackgroundResource(R.drawable.bottom_right_edge); insideLeftImageView.setBackgroundResource(R.drawable.bottom_right_edge); // this is not a mistake insideRightImageView.setBackgroundResource(R.drawable.bottom_left_edge); } else {/* w ww . j a v a2 s . c om*/ insideRightImageView.setBackgroundResource(R.drawable.left_edge); insideLeftImageView.setBackgroundResource(R.drawable.right_edge); } insideLeftImageView.setLayoutParams(new LayoutParams(height, width / 5)); insideRightImageView.setLayoutParams(new LayoutParams(height, width / 5)); insideRightImageView.getLayoutParams().height = height; insideLeftImageView.getLayoutParams().height = height; insideRightImageView.getLayoutParams().width = width / 5; insideLeftImageView.getLayoutParams().width = width / 5; tableRow.addView(insideLeftImageView, this.width - 1); tableRow.addView(insideRightImageView, this.width); } else { // this is a determinant button } leftImageView.setLayoutParams(new LayoutParams(height, width / 10)); rightImageView.setLayoutParams(new LayoutParams(height, width / 10)); leftImageView.getLayoutParams().height = height; rightImageView.getLayoutParams().height = height; leftImageView.getLayoutParams().width = width / 5; rightImageView.getLayoutParams().width = width / 5; tableRow.addView(leftImageView, 0); tableRow.addView(rightImageView); return tableRow; }
From source file:fr.enseirb.odroidx.remote_client.MainActivity.java
@Override public void requestFailed(String request, String message, String command) { Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show(); if (STBCommunication.REQUEST_SCAN.equals(request)) { scanningDialog.dismiss();//from www . j a v a 2s . com scanFailDialog.show(getSupportFragmentManager(), "scanfaildialog"); } for (ImageView iv : buttons) { iv.setBackgroundResource(R.color.black); } }
From source file:android.support.v17.leanback.supportleanbackshowcase.cards.CharacterCardView.java
public CharacterCardView(Context context) { super(context, null, R.style.CharacterCardStyle); LayoutInflater.from(getContext()).inflate(R.layout.character_card, this); setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override/*from www. j a v a 2s . c om*/ public void onFocusChange(View v, boolean hasFocus) { ImageView mainImage = (ImageView) findViewById(R.id.main_image); View container = findViewById(R.id.container); if (hasFocus) { container.setBackgroundResource(R.drawable.character_focused); mainImage.setBackgroundResource(R.drawable.character_focused); } else { container.setBackgroundResource(R.drawable.character_not_focused_padding); mainImage.setBackgroundResource(R.drawable.character_not_focused); } } }); setFocusable(true); }
From source file:com.javielinux.utils.SplitActionBarMenu.java
private void loadActionButtons(ArrayList<String> codes, final InfoTweet infoTweet, final long ownerColumn) { main_layout.removeAllViews();/* w w w.j a va 2 s. c o m*/ boolean is_first = true; for (final String code : codes) { if (is_first) { is_first = false; } else { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 0.0f); layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; ImageView imageView = new ImageView(activity); imageView.setBackgroundResource(R.drawable.action_bar_divider); imageView.setLayoutParams(layoutParams); main_layout.addView(imageView); } final InfoSubMenuTweet infoSubMenuTweet = new InfoSubMenuTweet(activity, code); ImageButton imageButton = new ImageButton(activity); imageButton.setBackgroundResource(R.drawable.default_background); int padding = (int) activity.getResources().getDimension(R.dimen.default_padding); imageButton.setPadding(padding, padding, padding, padding); imageButton.setImageResource(infoSubMenuTweet.getResDrawable()); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideSplitActionBarMenu(); TweetActions.execByCode(code, activity, ownerColumn, infoTweet, getFromFragment()); } }); imageButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { Utils.showMessage(activity, activity.getResources().getString(infoSubMenuTweet.getResName())); return true; } }); main_layout.addView(imageButton); } }
From source file:fr.enseirb.odroidx.remote_client.MainActivity.java
@Override public void requestSucceed(String request, String message, String command) { if (STBCommunication.REQUEST_SCAN.equals(request)) { new STBCommunicationTask(this, serviceConnection.getSTBDriver()) .execute(STBCommunication.REQUEST_CONNECT, message); scanningDialog.dismiss();//ww w . j ava2s .c om } else if (STBCommunication.REQUEST_CONNECT.equals(request)) { buttons_layout.setVisibility(View.VISIBLE); connected = true; invalidateOptionsMenu(); } else if (STBCommunication.REQUEST_DISCONNECT.equals(request)) { buttons_layout.setVisibility(View.GONE); } for (ImageView iv : buttons) { iv.setBackgroundResource(R.color.black); } }
From source file:com.kkbox.toolkit.app.KKTabFragment.java
protected void initView(View view, int[] buttonTextResourcetId, boolean showSubFragmentAnimation, int currentIndex) { fixStateForNestedFragment();/*from w w w . j av a2s .c om*/ initView(view); if (this.currentIndex == -1) { this.currentIndex = currentIndex; } this.showSubFragmentAnimation = showSubFragmentAnimation; radioGroup = (RadioGroup) view.findViewById(R.id.button_radiogroup); TypedValue typedValue = new TypedValue(); getActivity().getTheme().resolveAttribute(R.attr.KKTabFragmentStyle, typedValue, true); TypedArray array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { R.attr.KKTabButtonBackgroundLeft, R.attr.KKTabButtonBackgroundMiddle, R.attr.KKTabButtonBackgroundRight }); int tabButtonBackgroundLeftResourceId = array.getResourceId(0, -1); int tabButtonBackgroundMiddleResourceId = array.getResourceId(1, -1); int tabButtonBackgroundRightResourceId = array.getResourceId(2, -1); array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { R.attr.KKTabBackground }); int backgroundResourceId = array.getResourceId(0, -1); FrameLayout layoutRadioBar = (FrameLayout) view.findViewById(R.id.layout_radio_bar); if (backgroundResourceId != -1) { layoutRadioBar.setBackgroundResource(backgroundResourceId); } array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { R.attr.KKTabOverlay }); int overlayResourceId = array.getResourceId(0, -1); ImageView viewOverlay = (ImageView) view.findViewById(R.id.view_overlay); if (overlayResourceId != -1) { viewOverlay.setBackgroundResource(overlayResourceId); } array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { android.R.attr.textSize }); int textSize = array.getDimensionPixelSize(0, -1); array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { android.R.attr.textColor }); ColorStateList textColor = array.getColorStateList(0); array.recycle(); array = getActivity().obtainStyledAttributes(typedValue.resourceId, new int[] { android.R.attr.height }); int height = array.getDimensionPixelSize(0, -1); array.recycle(); for (int i = 0; i < buttonTextResourcetId.length; i++) { RadioButton radioButton = new RadioButton(getActivity()); if (i == 0 && tabButtonBackgroundLeftResourceId != -1) { radioButton.setBackgroundResource(tabButtonBackgroundLeftResourceId); } else if (i == buttonTextResourcetId.length - 1 && tabButtonBackgroundRightResourceId != -1) { radioButton.setBackgroundResource(tabButtonBackgroundRightResourceId); } else if (tabButtonBackgroundMiddleResourceId != -1) { radioButton.setBackgroundResource(tabButtonBackgroundMiddleResourceId); } radioButton.setText(buttonTextResourcetId[i]); radioButton.setButtonDrawable(new StateListDrawable()); radioButton.setGravity(Gravity.CENTER); radioButton.setTextColor(textColor); radioButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); radioButton.setLayoutParams(new RadioGroup.LayoutParams(0, height, 1)); radioButton.setOnClickListener(buttonClickListener); radioGroup.addView(radioButton); } currentFragment = null; radioGroup.getChildAt(this.currentIndex).performClick(); }