Error non-default constructors in fragments
if you like to be out of rules just do next
@SuppressLint("ValidFragment")
public PlaceDialogFragment(Place place, DisplayMetrics dm){
super();
this.mPlace = place;
this.mMetrics = dm;
}
Because of the nature of fragment and how there managed and shown on your screen it's very recommended not to create a non default constructor and in many cases this would cause problems in run time. In case you should do something like this:
public static final GridFragment newInstance(String tabId)
{
GridFragment f = new GridFragment();
Bundle bdl = new Bundle(2);
bdl.putString(TAB_ID, tabId);
f.setArguments(bdl);
return f;
}
and in onCreate extract the needed data from the bundle:
@Override
public void onCreate(Bundle savedInstanceState)
{
String tabId = getArguments().getString(TAB_ID);
}
And take a look at this question as well:
Do fragments really need an empty constructor?
@SuppressLint({"NewApi", "ValidFragment"})
public PlaceDialogFragment(Place place, DisplayMetrics dm){
super();
}
The easier way is to add these to the gradle:
android {
lintOptions {
checkReleaseBuilds false
}
}
Or you can add this line in each fragment
@SuppressLint("ValidFragment")
public PlaceDialogFragment(Place place, DisplayMetrics dm){
super();
this.mPlace = place;
this.mMetrics = dm;
}
Best solution is add lines in gradle simply.