The method show(FragmentManager, String) in the type DialogFragment is not appli

The method show(FragmentManager, String) in the type DialogFragment is not applicable for the arguments (FragmentManager, String)

 

	public static class MyDialogFragment extends DialogFragment {

		AlertDialog dialog = null;

		@Override
		public Dialog onCreateDialog(Bundle savedInstanceState) {

			AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
			// Get the layout inflater
			LayoutInflater inflater = getActivity().getLayoutInflater();

			View container = inflater.inflate(R.layout.dialog_layout, null);
			Button btnIPCall = (Button) container
					.findViewById(R.id.btn_ip_call);
			btnIPCall.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					if (dialog != null)
						dialog.dismiss();
				}
			});
			Button btnNormalCall = (Button) container
					.findViewById(R.id.btn_normal_call);
			btnNormalCall.setOnClickListener(new View.OnClickListener() {

				@Override
				public void onClick(View v) {
					if (dialog != null)
						dialog.dismiss();

				}
			});

			// Inflate and set the layout for the dialog
			// Pass null as the parent view because its going in the dialog
			// layout
			builder.setView(container);
			dialog = builder.create();
			return dialog;
		}

	}

 

 开发时遇到上述错误(红色字体),找了好久。原因原来是:

import android.support.v4.app.DialogFragment;

 改为导入

import android.app.DialogFragment;

 就正常了。

 

或者

public class MainActivity extends Activity {

 改为

public class MainActivity extends FragmentActivity {

 

 

当然也有可能是其他原因造成的,可以尝试

As you're using android.support.v4.app.DialogFragment, you should pass to show() an instance of android.support.v4.app.FragmentManager which can be queried using an getSupportFragmentManager() call. Hope this helps.

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值