我找到了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