サービスクラス上のLinearLayoutのためのアルファを設定する方法このようなレイアウト:私はit.The <code>WindowManager</code>で<code>WindowManager</code>はit.The <code>LinearLayout</code>でシンプル<code>LinearLayout</code>含ま空で、transparent.Iは、そのためのアルファ値を設定しようとしています含まれているサービスクラスを持っている
leftSwipe.getBackground().setAlpha(100) //leftSwipe is a LinearLayout
しかし、私はこのようなエラーを取得しています:
Unable to create service com.example.adarsh.test.Window: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.setAlpha(int)' on a null object reference
なぜそれが私のLinearLayout
が0123に存在していても私にNullPointerException
を与えています.IはこのようLinearLayout
を使用しています
LinearLayout l=new LinearLayout(this);
LinearLayout.LayoutParams leftS=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
l.getBackground().setAlpha(100);
l.setLayoutParams(leftS);
listWindow.addView(l, myParams); //listWindow is my WindowManager