Android App building : myFirstApp

Getting started on building first android app as tutorial from Google developer.

Few points to catch if you got stuck.


Error messages :

  • Error:(58, 17) error: cannot find symbol method openSearch()
  • Error:(61, 17) error: cannot find symbol method openSettings()

Solution : Add the following Functions to your Class :

public boolean openSettings(){
return true;
}

public boolean openSearch(){
return true;
}


Error messages :

  • Error:(20, 9) error: cannot find symbol variable getActionBar : 
  • Error:(20, 9) error: cannot find symbol variable getSupportActionBar

Solution : Add the following Functions to your Class :

ActionBar actionBar = getSupportActionBar();
getSupportActionBar.setDisplayHomeAsUpEnabled(true);


 

  • Error : Search Button not rendering in the Action Bar :

Solution : Implement the following in the main activity xml ;

<menu xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
xmlns:myfirstapp=”http://schemas.android.com/apk/res-auto&#8221; >
xmlns:tools=”http://schemas.android.com/tools&#8221;
tools:context=”.MainActivity” >

<item android:id=”@+id/action_search”
android:title=”@string/action_search”
android:icon=”@drawable/ic_action_search”
android:showAsAction=”always”
myfirstapp:showAsAction=”always”
/>
<item android:id=”@+id/action_settings”
android:title=”@string/action_settings”
android:showAsAction=”never”
myfirstapp:showAsAction=”never” />
</menu>


Also remember to import :

import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;