本文介绍了我正在一个错误"该方法秀(FragmentManager,字符串)"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个错误在类型DialogFragment的方法展示(FragmentManager,字符串)并不适用于参数(FragmentManager,字符串)请人帮我。

 包com.example.test1;

进口android.os.Bundle;
进口android.app.Activity;
进口android.view.Menu;
进口android.view.View;
进口android.support.v4.app.DialogFragment;
进口android.support.v4.app.Fragment;
进口android.support.v4.app.FragmentManager;
进口android.support.v4.app.FragmentActivity;

公共类MainActivity延伸活动{

@覆盖
公共无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    的setContentView(R.layout.activity_main);
}

公共无效点击(查看视图){
        DialogFragment newFragment =新FireMissilesDialogFragment();
        newFragment.show(getFragmentManager(),导弹);
}

公共布尔onCreateOtionsMenu(功能菜单){
    。getMenuInflater()膨胀(R.menu.activity_main,菜单);
    返回true;
}
}
 

解决方案

当你使用 android.support.v4.app.DialogFragment ,你应该传递给显示() android.support.v4.app.FragmentManager 可查询的使用<$ C $实例C> getSupportFragmentManager()通话。希望这有助于。

I am getting an error "The method show(FragmentManager, String) in the type DialogFragment is not applicable for the arguments (FragmentManager, String)"Please anyone help me.

package com.example.test1;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentActivity;

public class MainActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

public void click(View view) {
        DialogFragment newFragment = new FireMissilesDialogFragment();
        newFragment.show(getFragmentManager(), "missiles");
}

public boolean onCreateOtionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}
}
解决方案

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.

这篇关于我正在一个错误&QUOT;该方法秀(FragmentManager,字符串)&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 21:02