Can't referr to my get method
Posted
by
chility
on Stack Overflow
See other posts from Stack Overflow
or by chility
Published on 2014-05-25T15:21:23Z
Indexed on
2014/05/28
3:26 UTC
Read the original article
Hit count: 144
I have this amazing and good looking class:
public class SayingsHolder extends Application{
ArrayList<String> SayingsList = new ArrayList<String>(){{
SayingsList.add("1");
SayingsList.add("2");
}};
public ArrayList<String> getSayingsList() {
return SayingsList;
}
}
Now I'm trying to call the getSayingsList
method inside of my activity's FragmentStatePagerAdapter
by:
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
final SayingsHolder holder = (SayingsHolder).getApplication();
}
Everything fine for now, but when I make my code like this:
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
final SayingsHolder holder = (SayingsHolder).getApplication();
holder.getSayingsList();
}
it says:
Syntax error on token "getSayingsList", Identifier expected after this token
The problem is that holder
is not functional at all. What I mean is that when i type the this holder.
the getSayingsList
is not showing at all.
What am I missing here? I know that it is an extremely small issue, but it seems that I can't spot it. My activity extends FragmentActivity
if it's important
It seems that I'm missing something here. I can't call my method anywhere in my activity. I'm starting a bounty, because I need an example.
© Stack Overflow or respective owner