I am trying to load a Toast
Messagge. Inside a class that "paints"
a ViewPager
. The problem is that I am having an error when it comes to picking up the context. What could I be doing wrong?
public class ScreenSlidePageFragment extends Fragment {
public void onCreate(Bundle savedInstanceState){...}
public void onCreateView(Bundle savedInstanceState) {
Button btnTick = (Button) rootView.findViewById(R.id.buttonInvertirTick);
btnTick.setOnClickListener(new View.OnClickListener() {
public void onClick (View v) {
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
});
}
}
I have not copied all the code since the post would be somewhat longer and the error is as follows Can not resolve'getApplicationContext () '