我正在使用DialogFragments做很多事情:从列表中选择项目,输入文本.
将值(即字符串或列表中的项)返回给调用活动/片段的最佳方法是什么?
目前我正在制作调用活动实现DismissListener
,并为DialogFragment提供对活动的引用.然后,Dialog调用OnDimiss
activity中的方法,activity将从DialogFragment对象中获取结果.非常混乱,因为DialogFragment失去对活动的引用,它不能用于配置更改(方向更改).
谢谢你的帮助.
我发现消息无法解析方法'getSupportFragmentManager()'我想要片段化为活动.因为我想在选项卡上使用地图滑动.
public class PETAcikarangsukatani extends Fragment {
Context context;
private static final LatLng SUKATANI = new LatLng(-6.171327, 107.178108);
private static final LatLng WRPOJOK = new LatLng(-6.222411, 107.162158);
private static final LatLng PILAR = new LatLng(-6.257033, 107.156472);
private static final LatLng CIKARANG = new LatLng(-6.256073, 107.143984);
GoogleMap googleMap;
final String TAG = "PathGoogleMapActivity";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_path_google_map, container, false);
context = rootView.getContext();
SupportMapFragment fm = (SupportMapFragment)getSupportFragmentManager()
.findFragmentById(R.id.map);
googleMap = fm.getMap();
Run Code Online (Sandbox Code Playgroud)