Android的发展:未定义的方法 [英] Android Development: Undefined Method
问题描述
喜I'm新到Android和Eclipse。我刚刚从下面的developer.android.com教程。眼下I'm在增加动作条
Hi I´m new to Android and Eclipse. I have just following the tutorial from developer.android.com. Right now I´m in adding ActionBar
现在I'm在这个部分
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_search:
openSearch();
return true;
case R.id.action_settings:
openSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
我收到一个错误 OpenSearch的()
和 openSettings()
。它说,该方法 openSettings()
是未定义类型 DisplayMessageActivity
。我768,16现在怎么办?
谢谢
I have received an error for openSearch()
and openSettings()
. It said that The method openSettings()
is undefined for the type DisplayMessageActivity
. What shoud I do now?
Thanks
推荐答案
OpenSearch的()
和 openSettings()
是为了创建教程的作者执行其他操作的方法。搜索早已进入code,必须有这些方法某处的声明,如果作者让他们看到。
openSearch()
and openSettings()
are methods that the author of the tutorial created in order to perform other operations. Search well into the code, there must be somewhere the declaration of those methods, if the author made them visible.
他们应该是这个样子:
public void openSearch() {
//Do something here.
}
public void openSettings() {
//Do something here.
}
更换 //这里做什么
与本教程中的code实现present。
Replacing the //Do something here
with the code implementation present in the tutorial.
这篇关于Android的发展:未定义的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!