Reputation: 73
In a sub class of PopupWindow the onCreate methods don't seem available from the super class. Get the error "cannot resolve method onCreate()".
All the other methods are available.
Thanks.
import android.widget.PopupWindow;
public class MyPopupWindow extends PopupWindow
{
public void MyPopupWindow()
{
super.onCreate();
}
}
Upvotes: 1
Views: 621
Reputation: 73
Many thanks for the replies. Was doing so pretty basic mistakes. Have managed to create the class properly now and is doing as intended. Highlights the view that was tapped and unhighlights it once the popup is dismissed.
public class MyPopupWindow extends PopupWindow
{
private View tv;
private int bc;
MyPopupWindow(View vvv,int width,int height,View tappedView,int backColor)
{
super(vvv,width,height);
tappedView.setBackgroundColor(0xFFffb6c1);
tv = tappedView;
bc = backColor;
}
@Override
public void dismiss()
{
if (tv != null)
tv.setBackgroundColor(bc);
super.dismiss();
}
}
Upvotes: 1
Reputation: 823
The "super" keyword is used to invoke an overridden superclass's method. In this case MyPopupWindow() is not a method of the superclass PopupWindow and isn't overriding a method.
See "Using the Keyword super".
PopupWindow also doesn't have the method onCreate(), because it isn't an Activity or Fragment.
See Android PopupWindow reference.
Upvotes: 4