🧠
MindDB
  • MindDB
  • About Me
  • Bhaumik Mistry
  • Projects
  • Arsenal
    • Games 2019 2020
  • Count-It
    • 2020 Books
    • 2020 Games
    • 2020 Movies
    • 2020 TV Series
    • 2021 All Information
  • Drawingbook
    • Instagram Drawing Book
    • Pixel art book
    • A to P sketches
      • A
      • B
      • C
      • D
      • E
      • F
      • G
      • H
      • I
      • J
      • K
      • L
      • M
      • N
      • P
  • General Knowledge
    • Travel
    • Memory
    • Anger and Hunger
  • Mac
    • OS X version from command line
    • System setup
  • Physics
    • Aerodynamics
    • James Glashier
  • Space
    • Kepler space telescope
    • K2-18b
    • Parsec
  • Software
    • Advent of Code
    • Android
      • Icons
      • Snippets
    • C++
      • Code
        • If-else Vs Ternary
        • Best Fitting Plane
        • To Do
    • Chrome Extension
    • Git
    • iphone
    • PaaS
      • Heroku
      • Docker
    • People
      • Paul Graham
      • Ben Kuhn
    • Python
      • Pytest
      • UUID
  • Sports
    • Football(soccer)
      • EPL
    • Basketball
  • Stocks
    • TARP
Powered by GitBook
On this page
  • Index
  • Change png icon color from drawable resources or runtime
  • Remove notification bar and make app full screen
  • Add dialog box for alert

Was this helpful?

  1. Software
  2. Android

Snippets

PreviousIconsNextC++

Last updated 5 years ago

Was this helpful?

Index

Change png icon color from drawable resources or runtime

 Drawable mIcon= ContextCompat.getDrawable(getActivity(), R.drawable.your_icon);
    mIcon.setColorFilter(ContextCompat.getColor(getActivity(), R.color.new_color), PorterDuff.Mode.MULTIPLY);
    mImageView.setImageDrawable(mIcon);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, color);

Remove notification bar and make app full screen

WindowManager.LayoutParams attrs = this.getWindow().getAttributes();
        attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
        this.getWindow().setAttributes(attrs);

Place this code in MainActivity OnCreate()

Add dialog box for alert

AlertDialog.Builder builder1 = new AlertDialog.Builder(context);
builder1.setMessage("Write your message here.");
builder1.setCancelable(true);

builder1.setPositiveButton(
    "Yes",
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            /* DoSomethingWhenUserSaysYes() */
        }
    });

builder1.setNegativeButton(
    "No",
    new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            /* DoSomethingWhenUserSaysNo() */
        }
    });

AlertDialog alert11 = builder1.create();
alert11.show();
Change png icon color from drawable resources or runtime
Remove notification bar and make app full screen
Add dialog box for alert