Android : Cannot make a static reference to the non-static method show(FragmentManager, String) from the type DialogFragment

on Saturday, October 11, 2014


Hey Guys i'm having a few issues with I think importation. I'm getting the error message in the title under MyDialog.show(manager, "MyDialog");


Anybody know what it means? I'm thinking some issue with importing but i'm not to sure.


Rest of code:



package com.example.sub_assignment1_2;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;



/**
* A simple {@link Fragment} subclass.
*
*/
public class FragmentB extends Fragment implements MyDialog.Communicator {

public FragmentB() {
// Required empty public constructor
}


public void showDialog(View v)

{
FragmentManager manager=getFragmentManager();
MyDialog myDialog=new MyDialog();
MyDialog.show(manager, "MyDialog");
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_b, container, false);
}


@Override
public void onDialogMessage(String message) {
Toast.makeText(this, message,Toast.LENGTH_SHORT).show();

}

}


I'm also having an issue under Toast.makeText(this, message,Toast.LENGTH_SHORT).show(); The displayed error is: Toast.makeText(this, message,Toast.LENGTH_SHORT).show(); Which i'm also thinking is an import error?


If anybody could help that would be great.


0 comments:

Post a Comment