So, my program works fine. I only have three warnings left (one for each popupwindow) and it annoys me alot, I've been serching around for a solution that would fit my needs but I can't seem to find one.
This is my code (the other two popupwindows are similar)
else if(id == R.id.action_resetstats){
LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.resetpop, null);
final PopupWindow popupWindow = new PopupWindow(popupView,LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Button yesDismiss = (Button)popupView.findViewById(R.id.yesDismiss);
yesDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v){
SharedPreferences prefs = getSharedPreferences(savedData, Context.MODE_PRIVATE);
Editor editor = prefs.edit();
editor.clear();
editor.commit();
counterW = 0;
counterL = 0;
counterT = 0;
counterTot = 0;
timerTime = 3;
popupWindow.dismiss();
}
});
popupWindow.showAsDropDown(yeDismiss, 50, 50);
Button noDismiss = (Button)popupView.findViewById(R.id.noDismiss);
noDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v){
popupWindow.dismiss();
}
});
popupWindow.showAsDropDown(naDismiss, 50, 50);
xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@android:color/black"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="230dp"
android:layout_height="300dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="2dp"
android:background="@android:color/darker_gray"
android:orientation="vertical" >
<Button
android:id="@+id/noDismiss"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="NO!" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=" Reset stats?"
android:textSize="22sp" />
</RelativeLayout>
<Button
android:id="@+id/yesDismiss"
android:layout_width="100dp"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Yes" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/relativeLayout1"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:text="Are you sure you want " />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:text="to reset your statistics?" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:text="!CANNOT BE UNDONE!" />
</RelativeLayout>
</RelativeLayout>
The problem is here to clear things up:
View popupView = layoutInflater.inflate(R.layout.resetpop, null);
and the warning says:
Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)
Any ideas how to solve this the best way? Thanks in advance!
You could just use:
That should solve the warning.