The method getString(int) is undefined for the type Apps

idroid8 picture idroid8 · Oct 21, 2012 · Viewed 25.6k times · Source

How do I fix this error. All the three strings on the bottom get the following error "the method getString(int) is undefined for the type Apps". Please help, im such a noob.

package com.actionbarsherlock.sample.fragments;

import android.content.Context;
import android.content.res.Resources;


public final class Apps {
/**
 * Our data, part 1.
 */
public static final String[] TITLES =
{
        "title1",
        "title2",
        "title3"
};

/**
 * Our data, part 2.
 */
public static final String[] DIALOGUE = { 

    getString(R.string.text1),

    getString(R.string.string2),

    getString(R.string.string3)

};
}

Answer

Mohsin Naeem picture Mohsin Naeem · Oct 21, 2012

pass a instance of Context context

and then use

context.getResources().getString(R.string.text1)

here context is belongs to your current activity.