Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Development: Undefined Method

Tags:

android

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

Right now I´m at this part

@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);
    }
}

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

like image 818
Carlos Avatar asked Aug 16 '26 06:08

Carlos


1 Answers

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.

They should look something like this:

public void openSearch() {
    //Do something here.
}

public void openSettings() {
    //Do something here.
}

Replacing the //Do something here with the code implementation present in the tutorial.

like image 78
ClaireG Avatar answered Aug 18 '26 16:08

ClaireG