액티비티의 특정 값을 안드로이드의 조각으로 전달하고 싶습니다. 여기 은 일부 코드입니다 : -액티비티의 값을 조각 안드로이드로 전달
MainActivity : -
PlaceDialogFragment dialogFragment = new PlaceDialogFragment(place,dm);
조각 - 조각의 생성자를 사용
public PlaceDialogFragment(Place place, DisplayMetrics dm){
super();
this.mPlace = place;
this.mMetrics = dm;
}
나에게 오류를 제공합니다 : -
Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead
만약 내가 가진 생성자를 대체 : -
public static final DialogFragment newInstance(Place place, DisplayMetrics dm)
{
DialogFragment fragment = new DialogFragment();
Bundle bundle = new Bundle(2);
bundle.putParcelable("Place", place);
bundle.putFloat("Metrics", dm.density);
fragment.setArguments(bundle);
return fragment ;
}
(210) 나는 MainActivity.Java에 오류가 : -이
The constructor PlaceDialogFragment(Place, DisplayMetrics) is undefined
어떻게이 문제를 해결합니까?
조각에는 인수 생성자가 없어야한다. 알렉스가 당신의 질문에 대답했습니다. have look @ @ http://developer.android.com/reference/android/app/DialogFragment.html – Raghunandan