我运行以下代码:
public class MainActivity extends ActionBarActivity
{
ExpandableListAdapter listAdapter;
ExpandableListView expListView;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;
public static final String PREFS_NAME = "MyPrefsFile";
static SharedPreferences mPrefs;
SharedPreferences.Editor shPrefEditor;
public int BlackBackground=0, SleepScreen=1;
static MenuInflater inflater;
public ActionBar ab;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mPrefs = getSharedPreferences(PREFS_NAME, 0);
shPrefEditor = mPrefs.edit();
BlackBackground = mPrefs.getInt("BlackBackground", 0);
inflater = getMenuInflater();
...
模拟器在以下情况下崩溃(NullPointerException):
inflater = getMenuInflater();
有谁知道为什么?我该如何解决?