我找到了this。所以,遠沒有運氣。我用他的代碼,但我無法通過這個錯誤..我不熟悉充氣器。那麼有人可以解釋這段代碼嗎?創建透明傳遞活動
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) getApplicationContext()
.getSystemService(Context.WINDOW_SERVICE);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
ViewGroup mTopView = (ViewGroup) getApplicationContext()
.getLayoutInflater().inflate(R.layout.activity_invisible, null);
getWindow().setAttributes(params);
wm.addView(mTopView, params);
的這部分代碼:
ViewGroup mTopView = (ViewGroup) getApplicationContext()
.getLayoutInflater().inflate(R.layout.activity_invisible, null);
給了我這個錯誤The method getLayoutInflater() is undefined for the type Context
有人能解釋我做錯了嗎?
你在哪裏嘗試執行此代碼? –
'onCreate()'方法本身。 –
可能是因爲上下文中沒有getLayoutInflater()方法。嘗試使用您的活動,例如。或者像上面那樣,getSystemService – njzk2