我正在尝试阅读Fragment中的SharedPreferences.我的代码是我用来获取任何其他Activity的首选项.
SharedPreferences preferences = getSharedPreferences("pref", 0);
Run Code Online (Sandbox Code Playgroud)
我收到错误
Cannot make a static reference to the non-static method getSharedPreferences(String, int) from the type ContextWrapper
Run Code Online (Sandbox Code Playgroud)
我试图遵循这些链接,但没有运气通过静态方法和 静态SharedPreferences 访问SharedPreferences.谢谢你的任何解决方案.
我正在使用Action Bar Sherlock Fragment Tabs Pager中的示例.我想要做的是为每个标签设置不同的图标图像.每个选项卡的文本不是必需的,它可以包含在图像文件中.有这个问题的简单解决方案.
我最近遇到了一个问题.这是事情,我正在尝试从NSArray获取一个浮动对象来保存它,而我所能得到的只是(null).显然不是我想要收到的东西.看一下代码片段:
h = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithFloat:1.0],[NSNumber numberWithFloat:1.0],[NSNumber numberWithFloat:1.0], nil];
x = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithFloat:1.0],[NSNumber numberWithFloat:2.0], nil];
y = [[NSMutableArray alloc] init];
int step = 15; // That is just a random value, will depend on size of h and x.
for (int i = 0; i < step; ++i) {
NSLog(@"step = %i", i);
NSMutableArray *xTemp = [[NSMutableArray alloc] initWithArray:x];
NSMutableArray *hTemp = [[NSMutableArray alloc] initWithArray:h];
for (int j = 0; j < 3; ++j) {
float xToMul …Run Code Online (Sandbox Code Playgroud)