0

i want to add a search menu to my SherlockFragmentActivity, this is my code :

public class Home extends SherlockFragmentActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getSupportMenuInflater();
    inflater.inflate(R.menu.home_menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.home_search:
        Intent i = new Intent(getApplicationContext(), SearchActivity.class);
        startActivity(i);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

and this is my menu xml code :

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:id="@+id/home_search"
    android:icon="@drawable/home_search"
    android:orderInCategory="100"
    android:showAsAction="always"/>

</menu>

when i run my app, i'm getting an exception : classnotfoundexception didn't find class "com.actionbarsherelock.R$styleable on path dexpathlist. What's the matter ?

1 Answers1

0

Right click on your project and select Properties.

->Select Java Build Path from the menu on the left.

->Select the Order and Export tab.

->From the list make sure the libraries or external jars you added to your project are checked.

then clean your project & run. This will help you to overcome the exception

-> also check this link Android ClassNotFoundException: Didn't find class on path

Community
  • 1
  • 1
Fay007
  • 2,707
  • 3
  • 28
  • 58
  • my jars are already checked, and i've tried that before posting my question but i'm getting the same problem – Mejdi Dallel May 02 '15 at 12:45
  • may be the error is in ur Manifest file. check this link: http://stackoverflow.com/questions/22399572/java-lang-classnotfoundexception-didnt-find-class-on-path-dexpathlist – Fay007 May 02 '15 at 12:49
  • can u share how u have added ur jar and also the manifest cause ur code is not the reason i guess – Fay007 May 02 '15 at 12:53
  • try uncheck the box dependency and also check if the support library in ur project and the library project are same or not – Fay007 May 02 '15 at 13:05