title: How do I assign a drawable to ImageView
body: <p>I am working on adding halo into cyanogenmod 11. And for that I am using a method which gets the state of halo being active or not, and then assigns image to it accordingly.</p>
  
  <p>First, here's my code from latest try (I have made multiple attempts to do this task)-></p>
  
  <pre><code>protected void updateHalo() {
  //mHaloActive is a boolean. mHaloButton is an ImageView
      mHaloActive = Settings.System.getInt(mContext.getContentResolver(),
              Settings.System.HALO_ACTIVE, 0) == 1;
      int resID;
      String mDrawableName;
      if (mHaloActive) {
          mDrawableName = "ic_notify_halo_pressed";
          resID = getResources().getIdentifier(mDrawableName, "drawable", getPackageName());
          mHaloButton.setImageResource(resID);
      } else {
          mDrawableName = "ic_notify_halo_normal";
          resID = getResources().getIdentifier(mDrawableName, "drawable", getPackageName());
          mHaloButton.setImageResource(resID);
      }
      if (mHaloActive) {
          if (mHalo == null) {
              LayoutInflater inflater = (LayoutInflater) mContext
                      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              mHalo = (Halo) inflater.inflate(R.layout.halo_trigger, null);
              mHalo.setLayerType(View.LAYER_TYPE_HARDWARE, null);
              WindowManager.LayoutParams params = mHalo.getWMParams();
              mWindowManager.addView(mHalo, params);
              mHalo.setStatusBar(this);
          }
      } else {
          if (mHalo != null) {
              mHalo.cleanUp();
              mWindowManager.removeView(mHalo);
              mHalo = null;
          }
      }
  }
  </code></pre>
  
  <p>Now here, it says <code>cannot find symbol: method getPackageName()</code></p>
  
  <p>Earlier I had made multiple attempts too like using <code>setImageResource(R.drawable.ic_notify_halo_pressed);</code>
  But that was giving me NPE.</p>
  
  <p>Then I also tried using:</p>
  
  <pre><code>Resources resources = getResources();        mHaloButton.setImageDrawable(resources.getDrawable(R.drawable.ic_notify_halo_pressed));
  </code></pre>
  
  <p>But this gave error <code>cannot find symbol: method getResources()</code></p>
  
  <p>And I also tried <code>mHaloButton.setImageDrawable(R.drawable.ic_notify_halo_pressed);</code> but it gives error: <code>setImageDrawable(android.graphics.drawable.Drawable) in android.widget.ImageView cannot be applied to (int)</code></p>
  
  <p>So I know it needs resource ID, but how do I get that?</p>
  
  <p>Please note: I am not building an application, and this is not a android studio project. I am trying to port halo to cyanogenmod 11.</p>