• 6
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

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

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.

  • 50
Reply Report
    • One more question, even after adding support api's, my app still does not look like Version 4.0 app. Still looks like gingerbread which my phone has. Is there anything else i need to do?
    • @user1767451, Support library is designed to let developers use new APIs on older Android versions, not for making the application look the same on all API versions.
      • 1
    • @user1767451, Actually your Activity class should extend FragmentActivity rather than simple Activity to allow you use Fragments.

The problem is because you need to be using the support package's FragmentManager but you are using the native FragmentManager when you call getFragmentManager(). Try calling getSupportFragmentManager() when initializing your variable fm

you also have to make sure that you include DialogFragment from the Support package and not from the native package.

You can do that by importing,

import android.support.v4.app.DialogFragment;
  • 30
Reply Report

Even i had the same problem when running the code in gingerbread. But works fine for ICS. The solution is,

instead of this:

public class MainActivity extends Activity {
}

use extends FragmentActivty

public class MainActivity extends FragmentActivity {
}
  • 19
Reply Report

I got this when opening a DialogFragment even though I was not using android.support.v4.app.DialogFragment. I had to call getActivity().getFragmentManager(), because getSupportFragmentManager() didn't work.

  • 3
Reply Report
public void onClick(View v) {

    switch (v.getId()) {
    case R.id.btnselectDate:
         DialogFragment newFragment = new DatePickerFragment();
         newFragment.show(this.getFragmentManager(), "datePicker");
         break;

         default:
         break;
     }
}
  • 2
Reply Report