List of usage examples for android.widget ImageView setImageDrawable
public void setImageDrawable(@Nullable Drawable drawable)
From source file:com.android.launcher2.Launcher.java
private void updateButtonWithDrawable(int buttonId, Drawable.ConstantState d) { ImageView button = (ImageView) findViewById(buttonId); button.setImageDrawable(d.newDrawable(getResources())); }
From source file:com.example.health_connect.MySampleFragment3.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mView = inflater.inflate(R.layout.sample_fragment3, container, false); Parse.initialize(mView.getContext(), "e0FVFRBMAWJi5shg4XF8zL3SIuRwDIufww3338so", "toTJmlHTEF43u7PoAFT4fedwqfhoWiSajj1Se7FT"); ParseUser currentUser = ParseUser.getCurrentUser(); Log.d("Check", currentUser.getObjectId()); ImageView birthdaypic = (ImageView) mView.findViewById(R.id.imageView2); TextView wish = (TextView) mView.findViewById(R.id.textView23); TextView hbday = (TextView) mView.findViewById(R.id.textView24); WebView webview = (WebView) mView.findViewById(R.id.pic); webview.setWebViewClient(new WebViewClient() { @Override/*from w ww.ja v a 2 s . co m*/ public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.i("WEB_VIEW_TEST", "error code: " + errorCode + " " + description); super.onReceivedError(view, errorCode, description, failingUrl); } }); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setDomStorageEnabled(true); String u_r_l; if (currentUser.getString("image_flag").equalsIgnoreCase("1")) { u_r_l = "http://cdn.filter.to/100x100/http://s3-ap-southeast-1.amazonaws.com/hconnect/" + currentUser.getObjectId(); } else { u_r_l = "http://cdn.filter.to/100x100/cdn1.iconfinder.com/data/icons/PRACTIKA/256/user.png"; } webview.loadUrl(u_r_l); String date_of_birth = currentUser.getString("Dob"); Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); String formattedDate = df.format(c.getTime()); //Log.d("Check",formattedDate); String str[] = { "Every patient carries her or his own doctor inside.", "Laughter is the best medicine", "The art of medicine consists in amusing the patient while nature cures the disease.", "Health is wealth", "My health is good,it's my age that's bad.", "A healthy body is a guest-chamber for the soul; a sick body is a prison.", "Fitness:If it came in a bottle,everybody would have a good body.", "Ypu don't get ulcers form what you eat,but from what's eating you.", "Those who don't find time for exercise will have to find time for illness.", "Sickness comes on horseback and departs on foot.", "Health and appetite impart the sweetness to sugar,bread and meat.", "Health is not valued till sickness comes.", "Health is not simply the absence of sickness.", "To eat is a necessity,but to eat intelligently is an art.", "Let food be the medicine,thy medicine shall be thy food.", "Food is fuel,choose wisely.", "Health and intellect are the two blessings of life.", "The greatest wealth is health.", "Think positive and focus on gratitude.", "Get a good night's sleep.", "Use food over supplements.", "Eat 5 servings of fruits and veggies a day.", "Big idea: Be happy :)", "Drink water instead of surgery drinks.", "Swap big serves for smaller ones.", "Park the car and walk the rest of the way.", "No disease that can be treated by diet should be treated with any other means.", "Your body hears everything your mind says/", "Take care of your body. It's the only place you have to live.", "Every human being is the author of his own health or disease." }; Random r = new Random(); int High = 30; // 30 excluded int Low = 0; int random_number = r.nextInt(High - Low) + Low; if ((formattedDate.substring(0, 2).equalsIgnoreCase(date_of_birth.substring(0, 2))) && (formattedDate.substring(3, 5).equalsIgnoreCase(date_of_birth.substring(3, 5)))) // if(d1==d2 && m1==m2) { } else { // Log.d("Check", d1); birthdaypic.setImageDrawable(null); wish.setText(null); hbday.setText(null); wish.setText(str[random_number]); //wish.setVisibility(View.GONE); hbday.setVisibility(View.GONE); } TextView a_name = (TextView) mView.findViewById(R.id.pdob); TextView a_eid = (TextView) mView.findViewById(R.id.textView8); TextView a_add = (TextView) mView.findViewById(R.id.textView10); TextView a_dob = (TextView) mView.findViewById(R.id.textView12); TextView a_lno = (TextView) mView.findViewById(R.id.textView14); TextView a_year = (TextView) mView.findViewById(R.id.textView16); TextView a_mschool = (TextView) mView.findViewById(R.id.textView18); TextView a_spec = (TextView) mView.findViewById(R.id.textView20); TextView a_deg = (TextView) mView.findViewById(R.id.textView22); a_name.setText(currentUser.getUsername()); a_deg.setText(currentUser.getString("Degree")); a_dob.setText(currentUser.getString("Dob")); a_spec.setText(currentUser.getString("Primary_speciality")); a_mschool.setText(currentUser.getString("Medical_School")); a_add.setText(currentUser.getString("Address")); a_year.setText(currentUser.getString("Start_Practice")); a_eid.setText(currentUser.getEmail()); a_lno.setText(currentUser.getString("LicenseNo")); return mView; }
From source file:cl.gisred.android.InspActivity.java
private void eliminarImg(ImageView img) { if (Build.VERSION.SDK_INT < 23) img.setAdjustViewBounds(true);/*from w ww. ja v a 2s . com*/ //img.setImageResource(android.R.color.transparent); img.setImageDrawable(null); Toast.makeText(getApplicationContext(), "Eliminado", Toast.LENGTH_SHORT).show(); }
From source file:com.android.launcher2.Launcher.java
private Drawable.ConstantState updateButtonWithIconFromExternalActivity(int buttonId, ComponentName activityName, int fallbackDrawableId, String toolbarResourceName) { ImageView button = (ImageView) findViewById(buttonId); Drawable toolbarIcon = getExternalPackageToolbarIcon(activityName, toolbarResourceName); if (button != null) { // If we were unable to find the icon via the meta-data, use a // generic one if (toolbarIcon == null) { button.setImageResource(fallbackDrawableId); } else {/* ww w .j av a 2 s . c o m*/ button.setImageDrawable(toolbarIcon); } } return toolbarIcon != null ? toolbarIcon.getConstantState() : null; }
From source file:self.philbrown.droidQuery.$.java
/** * Adds an Image over each selected View as a mask. * In most cases, this mask can be retrieved by querying siblings. For example: * <pre>/*from w w w . j a va 2 s.co m*/ * ImageView mask = (ImageView) $.with(myView).parent().selectChildren().selectImages().view(0); * </pre> * @param mask the drawable to draw * @return this */ public $ mask(Drawable mask) { for (View v : views) { ImageView image = new ImageView(context); image.setImageDrawable(mask); image.setScaleType(ScaleType.FIT_XY); ViewParent parent = v.getParent(); if (parent != null && parent instanceof ViewGroup) { image.setLayoutParams(v.getLayoutParams()); ((ViewGroup) parent).addView(image); } else if (v instanceof ViewGroup) { image.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ((ViewGroup) v).addView(image); } } return this; }
From source file:com.giovanniterlingen.windesheim.view.Adapters.ScheduleAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final TextView lessonName = holder.lessonName; final TextView lessonTime = holder.lessonTime; final TextView lessonRoom = holder.lessonRoom; final TextView lessonComponent = holder.lessonComponent; final RelativeLayout menuButton = holder.menuButton; final ImageView menuButtonImage = holder.menuButtonImage; final View scheduleIdentifier = holder.scheduleIdentifier; Lesson lesson = this.lessons[position]; long databaseDateStart = Long .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getStartTime().replaceAll(":", "")); long databaseDateEnd = Long .parseLong(lesson.getDate().replaceAll("-", "") + lesson.getEndTime().replaceAll(":", "")); SimpleDateFormat yearMonthDayDateFormat = CalendarController.getInstance().getYearMonthDayDateTimeFormat(); long currentDate = Long.parseLong(yearMonthDayDateFormat.format(new Date())); lessonName.setText(lesson.getSubject()); lessonRoom.setText(lesson.getRoom()); lessonComponent.setText(lesson.getScheduleType() == 2 ? lesson.getClassName() : lesson.getTeacher()); lessonComponent.setSelected(true);//from w w w .ja va 2s. com if (databaseDateStart <= currentDate && databaseDateEnd >= currentDate) { lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText( ApplicationLoader.applicationContext.getResources().getString(R.string.lesson_started)); holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (!lessonTime.getText().toString().equals(ApplicationLoader.applicationContext.getResources() .getString(R.string.lesson_started))) { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText(ApplicationLoader.applicationContext.getResources() .getString(R.string.lesson_started)); } else { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); } } }); } else if (databaseDateEnd < currentDate) { lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText(ApplicationLoader.applicationContext.getResources().getString(R.string.finished)); holder.cardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (!lessonTime.getText().toString().equals( ApplicationLoader.applicationContext.getResources().getString(R.string.finished))) { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorAccent)); lessonTime.setText( ApplicationLoader.applicationContext.getResources().getString(R.string.finished)); } else { TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(100); lessonTime.setAnimation(animation); String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); } } }); } else { String lessonTimes = lesson.getStartTime() + " - " + lesson.getEndTime(); lessonTime.setTextColor(ContextCompat.getColor(activity, R.color.colorSecondaryText)); lessonTime.setText(lessonTimes); holder.cardView.setOnClickListener(null); } menuButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { menuButtonImage.setImageDrawable( ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_open, null)); PopupMenu popupMenu = new PopupMenu(activity, menuButton); popupMenu.inflate(R.menu.menu_schedule); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Lesson lesson = ScheduleAdapter.this.lessons[holder.getAdapterPosition()]; if (item.getItemId() == R.id.hide_lesson) { showPromptDialog(lesson.getSubject()); return true; } if (item.getItemId() == R.id.save_lesson) { showCalendarDialog(lesson.getRowId()); } return true; } }); popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { menuButtonImage.setImageDrawable(ResourcesCompat.getDrawable(activity.getResources(), R.drawable.overflow_normal, null)); } }); popupMenu.show(); } }); scheduleIdentifier.setBackgroundColor(ColorController.getInstance().getColorById(lesson.getScheduleId())); }
From source file:com.cognizant.trumobi.PersonaLauncher.java
/** * ADW: Create a copy of an folder icon with a reflection * /*from w w w .j a v a 2s . c om*/ * @param layoutResId * @param parent * @param info * @return */ View createSmallFolder(int layoutResId, ViewGroup parent, PersonaUserFolderInfo info) { ImageView favorite = (ImageView) mInflater.inflate(layoutResId, parent, false); final Resources resources = getResources(); // Drawable d = resources.getDrawable(R.drawable.ic_launcher_folder); Drawable d = null; if (PersonaAlmostNexusSettingsHelper.getThemeIcons(this)) { String packageName = PersonaAlmostNexusSettingsHelper.getThemePackageName(this, THEME_DEFAULT); if (packageName.equals(THEME_DEFAULT)) { d = resources.getDrawable(R.drawable.pr_ic_launcher_folder); } else { d = PersonaFolderIcon.loadFolderFromTheme(this, getPackageManager(), packageName, "ic_launcher_folder"); if (d == null) { d = resources.getDrawable(R.drawable.pr_ic_launcher_folder); } } } else { d = resources.getDrawable(R.drawable.pr_ic_launcher_folder); } d = PersonaUtilities.drawReflection(d, this); favorite.setImageDrawable(d); PersonaLog.d("personalauncher", "------settag done in createsmallfolder-------"); favorite.setTag(info); favorite.setOnClickListener(this); return favorite; }
From source file:com.android.launcher3.Launcher.java
/** * Finds all the views we need and configure them properly. *//* w w w . j a v a 2 s . c o m*/ private void setupViews() { mLauncherView = findViewById(R.id.launcher); mDragLayer = (DragLayer) findViewById(R.id.drag_layer); mFocusHandler = mDragLayer.getFocusIndicatorHelper(); mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace); mQsbContainer = mDragLayer.findViewById( mDeviceProfile.isVerticalBarLayout() ? R.id.workspace_blocked_row : R.id.qsb_container); mWorkspace.initParentViews(mDragLayer); mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); // Setup the drag layer mDragLayer.setup(this, mDragController, mAllAppsController); // Setup the hotseat mHotseat = (Hotseat) findViewById(R.id.hotseat); if (mHotseat != null) { mHotseat.setOnLongClickListener(this); } // Setup the overview panel setupOverviewPanel(); setuphome(); // Setup the workspace mWorkspace.setHapticFeedbackEnabled(false); mWorkspace.setOnLongClickListener(this); mWorkspace.setup(mDragController); // Until the workspace is bound, ensure that we keep the wallpaper offset locked to the // default state, otherwise we will update to the wrong offsets in RTL mWorkspace.lockWallpaperToDefaultPage(); mDragController.addDragListener(mWorkspace); // Get the search/delete/uninstall bar mDropTargetBar = (DropTargetBar) mDragLayer.findViewById(R.id.drop_target_bar); // Setup Apps and Widgets mAppsView = (AllAppsContainerView) findViewById(R.id.apps_view); mWidgetsView = (WidgetsContainerView) findViewById(R.id.widgets_view); if (mLauncherCallbacks != null && mLauncherCallbacks.getAllAppsSearchBarController() != null) { mAppsView.setSearchBarController(mLauncherCallbacks.getAllAppsSearchBarController()); } else { mAppsView.setSearchBarController(new DefaultAppSearchController()); } // Setup the drag controller (drop targets have to be added in reverse order in priority) mDragController.setDragScoller(mWorkspace); mDragController.setScrollView(mDragLayer); mDragController.setMoveTarget(mWorkspace); mDragController.addDropTarget(mWorkspace); mDropTargetBar.setup(mDragController); if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) { mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace); } if (TestingUtils.MEMORY_DUMP_ENABLED) { TestingUtils.addWeightWatcher(this); } FrameLayout gBar = (FrameLayout) findViewById(R.id.g_bar); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams(); gBarLayout.width = Utils.getScreenXDimension(this) - Utils.getScreenXDimension(this) / 6; gBar.setLayoutParams(gBarLayout); } else { FrameLayout.LayoutParams gBarLayout = (FrameLayout.LayoutParams) gBar.getLayoutParams(); gBarLayout.width = Utils.getScreenYDimension(this) - Utils.getScreenYDimension(this) / 12; gBar.setLayoutParams(gBarLayout); } gBar.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startSearch("", false, null, true); } }); ImageView gSearch = (ImageView) findViewById(R.id.g_search); gSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startSearch("", false, null, true); } }); FrameLayout.LayoutParams gSearchLayout = (FrameLayout.LayoutParams) gSearch.getLayoutParams(); gSearchLayout.leftMargin = 30; gSearch.setLayoutParams(gSearchLayout); ImageView gSearchMic = (ImageView) findViewById(R.id.g_search_mic); if (IS_ALLOW_MIC) { gSearchMic.setVisibility(View.VISIBLE); gSearchMic.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); startActivityForResult(intent, RECOGNIZER_REQ_CODE); } }); } else { gSearchMic.setVisibility(View.GONE); } FrameLayout.LayoutParams gSearchMicLayout = (FrameLayout.LayoutParams) gSearchMic.getLayoutParams(); gSearchMicLayout.rightMargin = 30; gSearchMic.setLayoutParams(gSearchMicLayout); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (Utilities.isAllowNightModePrefEnabled(getApplicationContext())) { gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape_night)); gSearch.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon_night)); gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color)); gSearchMic .setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic_night)); gSearchMic.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.night_color)); } else { gBar.setBackground(ContextCompat.getDrawable(getApplicationContext(), R.drawable.shape)); gSearch.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.g_icon)); gSearch.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); gSearchMic.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.mic)); gSearchMic .setBackgroundColor(ContextCompat.getColor(getApplicationContext(), android.R.color.white)); } } if (!Utilities.isAllowPersisentSearchBarPrefEnabled(getApplicationContext())) { gBar.setVisibility(View.GONE); gSearch.setVisibility(View.GONE); gSearchMic.setVisibility(View.GONE); } else { gBar.setVisibility(View.VISIBLE); gSearch.setVisibility(View.VISIBLE); if (IS_ALLOW_MIC) { gSearchMic.setVisibility(View.VISIBLE); } else { gSearchMic.setVisibility(View.GONE); } } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
/** * ADW: Create a copy of an PersonaLiveFolder icon with a reflection * //from www . j a va 2 s . c om * @param layoutResId * @param parent * @param info * @return */ View createSmallLiveFolder(int layoutResId, ViewGroup parent, PersonaLiveFolderInfo info) { ImageView favorite = (ImageView) mInflater.inflate(layoutResId, parent, false); final Resources resources = getResources(); Drawable d = info.icon; if (d == null) { if (PersonaAlmostNexusSettingsHelper.getThemeIcons(this)) { // Drawable d = // resources.getDrawable(R.drawable.ic_launcher_folder); String packageName = PersonaAlmostNexusSettingsHelper.getThemePackageName(this, THEME_DEFAULT); if (packageName.equals(THEME_DEFAULT)) { d = resources.getDrawable(R.drawable.pr_ic_launcher_folder); } else { d = PersonaFolderIcon.loadFolderFromTheme(this, getPackageManager(), packageName, "ic_launcher_folder"); if (d == null) { d = resources.getDrawable(R.drawable.pr_ic_launcher_folder); } } } else { d = resources.getDrawable(R.drawable.pr_ic_launcher_folder); } info.filtered = true; } d = PersonaUtilities.drawReflection(d, this); favorite.setImageDrawable(d); PersonaLog.d("personalauncher", "------settag done in createsmalllivefolder-------"); favorite.setTag(info); favorite.setOnClickListener(this); return favorite; }