I couldn’t use context in FragmentPagerAdapter
. RadioGroup(this)
gives me undefined error. I used getContext()
instead of this but couldn’t achieve it
private static class MyFragmentPagerAdapter extends FragmentPagerAdapter {
final RadioGroup rg = new RadioGroup(this); // what can I use instead of "this" ?
}
I am not sure why you are instantiating a RadioGroup in a FragmentPagerAdapter, but anyway you can get the context by modifying the constructor of the class:
private Context context;
/** Constructor of the class */
public MyFragmentPagerAdapter(FragmentManager fm, Context c) {
super(fm);
context = c;
}
Then you can add the context when you create your FragmentPagerAdapter.
Tags: androidandroid, text