`
xinanadu
  • 浏览: 227314 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

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
8
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics