Vinuthan Vinuthan - 3 years ago 171
Android Question

I am getting an error "The method show(FragmentManager, String)"

I am getting an error


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



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;
}
}

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download