Fragment怎么引用ProgressDialog

Android 码拜 8年前 (2016-03-24) 1005次浏览
public class RecommendActivity extends Fragment implements OnFocusChangeListener{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
View rootView = inflater.inflate(R.layout.activity_recommend,container, false);
}
@Override
public void onPause() {
mBMapMan.getLocationManager().removeUpdates(mLocationListener);
mBMapMan.stop();
super.onPause();
}
@Override
public void onResume() {
mBMapMan.getLocationManager().requestLocationUpdates(mLocationListener);
mBMapMan.getLocationManager().enableProvider(MKLocationManager.MK_GPS_PROVIDER);
mBMapMan.start();
super.onResume();
}
//初始化百度地图
private void initBaiDuMap() {
mBMapMan = new BMapManager(getActivity().getApplication());
mBMapMan.init(“14A97FC2DDF678193F61C19C0A20EA29C49DEF5C”, null);
mBMapMan.start();
initMyLocation();
}
//启动定位
private void initMyLocation() {
progressDialog = ProgressDialog.show(this,null, “城市定位中…”,true, true);
}
progressDialog = ProgressDialog.show(this,null, “城市定位中…”,true, true); 这段话一直出这个错误
The method show(Context, CharSequence, CharSequence, boolean, boolean) in the type ProgressDialog is not applicable for the arguments (RecommendActivity, null, String, boolean, boolean)帮忙解决一下谢谢!
解决方案

25

参数不对,第一个参数是Context 你的是Fragment   你要获得一个activiyty的参数  你可以直接在fragment里面getactivity ()即contenxt参数

25

你的RecommendActivity   是继承的Fragment ,不是继承的Activity ,所以要获取Context对象 ,在第一个参数 用getActivity()就好了

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Fragment怎么引用ProgressDialog
喜欢 (0)
[1034331897@qq.com]
分享 (0)