Reputation: 314
I am trying to access requestWindowFeature()
from another Class called MyFunctions
here is my MyFunctions Class
public class MyFunctions {
Context context;
public MyFunctions(Context c)
{
c = context;
}
public void hideBars(Context context)
{
//HIDING TOP TITLE TAB
context.requestWindowFeature(Window.FEATURE_NO_TITLE);
//HIDING TOP TOOL BAR
context.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
but it showing an error like this
What should i do to access requestWindowFeature()
and getWindow()
from another class ?
Best answer will be apreciated!
Upvotes: 0
Views: 200
Reputation: 12933
getWindow()
and requestWindowFeature()
are methods of Activity
not Context
.
Pass a reference of the Activity
to your class / method.
public void hideBars(Activity activity)
{
//HIDING TOP TITLE TAB
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
//HIDING TOP TOOL BAR
activity.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Upvotes: 3