Search View Widget Crashes in ICS and above
When using the Search View Widget as a Action View in the latest sherlock with Ice Cream Sandwich or above it crashes complaining about a layout file.
I've fixed it by setting the code in my activity that uses a plain button for Eclair (As google recommends), The sherlock implementation from Froyo to Honeycomb and then the native one from Ice Cream Upwards.
I think the Sherlock Implementation should wrap around the native widget by default or is this not possible ? At least it should throw an error complaining it isn't compatible with anything newer than Honeycomb and the user should use the Native Widget
Stack trace? Example code? Demo project?
It works on all APIs using the example in the 'demos' sample app.
This is the error I got.
11-03 00:50:22.587: E/AndroidRuntime(928): FATAL EXCEPTION: main
11-03 00:50:22.587: E/AndroidRuntime(928): android.view.InflateException: Binary XML file line #29: Error inflating class
And here is the code that triggered it
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.widget.SearchView;
import com.NYXDigital.LookBunnyFind.Adapters.FragmentViewPagerAdapter;
import com.NYXDigital.LookBunnyFind.Fragments.BranchListFragment;
import com.NYXDigital.LookBunnyFind.Fragments.FindFragment;
import com.NYXDigital.LookBunnyFind.Widget.FragmentViewPagerItem;
import com.viewpagerindicator.*;
public class LookBunnyFindActivity extends SherlockFragmentActivity {
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create adapter for pager and add fragments to be displayed
FragmentViewPagerAdapter adapter = new FragmentViewPagerAdapter(
getSupportFragmentManager());
// Local
FragmentViewPagerItem localFragment = new FragmentViewPagerItem(
"Local", new BranchListFragment());
adapter.addFragment(localFragment);
// Find
FragmentViewPagerItem findFragment = new FragmentViewPagerItem("Find",
new FindFragment());
adapter.addFragment(findFragment);
// Events
FragmentViewPagerItem eventsFragment = new FragmentViewPagerItem(
"Events", new BranchListFragment());
adapter.addFragment(eventsFragment);
// Set the pager with an adapter
ViewPager pager = (ViewPager) findViewById(R.id.pager);
pager.setAdapter(adapter);
// Bind the title indicator to the adapter
TabPageIndicator mIndicator = (TabPageIndicator) findViewById(R.id.indicator);
mIndicator.setViewPager(pager);
}
public boolean onCreateOptionsMenu(Menu menu) {
// Create the Search Menu Item
MenuItem searchItem = menu.add("Search").setIcon(
R.drawable.abs__ic_search);
searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM
| MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
// Check Application is running on Android Froyo or Above
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO) {
// Create the search view
SearchView searchView = new SearchView(getSupportActionBar()
.getThemedContext());
searchView.setQueryHint("e.g Farm park");
// Setup Action View
searchItem.setActionView(searchView);
}
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
// If this is the search button then
if (item.getTitle() == "Search") {
this.onSearchRequested();
return true;
}
return false;
}
}
@jcampbell05 android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01002b a=-1}
What would cause that error ? Is that something in my code ?
same thing, crash with JB 4.2; Works with Android 2.2 though.
We are also seeing a similar crash, though it only seems to effect a few devices. I cannot reproduce it myself, but users report that the app crashes right away.
<item
android:id="@+id/menu_search"
android:icon="@drawable/ic_action_search_default"
android:actionViewClass="com.actionbarsherlock.widget.SearchView"
android:showAsAction="always|collapseActionView"
android:menuCategory="system"
android:orderInCategory="11"
android:title="@string/menu_search"/>
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getSupportMenuInflater().inflate(R.menu.base_menu, menu);
mSearchItem = menu.findItem(R.id.menu_search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView = (SearchView) mSearchItem.getActionView();
if( null != mSearchView ){
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
}
return true;
}
java.lang.RuntimeException: Unable to resume activity {com.zappos.android/com.zappos.android.activities.HomeActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x7f0d008e at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2634) ....... Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f0d008e at android.content.res.Resources.getText(Resources.java:229) at android.content.res.Resources.getString(Resources.java:313) at android.content.Context.getString(Context.java:292) at com.actionbarsherlock.widget.SearchView.updateQueryHint(SearchView.java:1090) at com.actionbarsherlock.widget.SearchView.setSearchableInfo(SearchView.java:371) at com.zappos.android.activities.BaseActivity.onCreateOptionsMenu(BaseActivity.java:176) at com.zappos.android.activities.BaseCartActivity.onCreateOptionsMenu(BaseCartActivity.java:246) at com.zappos.android.activities.HomeActivity.onCreateOptionsMenu(HomeActivity.java:323) at android.support.v4.app.Watson.onCreatePanelMenu(Watson.java:45) at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559) at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60) at com.actionbarsherlock.app.SherlockFragmentActivity.onCreatePanelMenu(SherlockFragmentActivity.java:165) at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:393) at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:747) at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchInvalidateOptionsMenu(ActionBarSherlockNative.java:49) at com.actionbarsherlock.app.SherlockFragmentActivity.invalidateOptionsMenu(SherlockFragmentActivity.java:150) at com.zappos.android.activities.HomeActivity.onResume(HomeActivity.java:403) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184) at android.app.Activity.performResume(Activity.java:5132) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2617)
I don't think that this is a device related issue. I'm encountering the crash in my app, but the sample is running fine (Galaxy Nexus, 4.2.1 stock). I'll see if I can get a minimal testcase.
Ok, this looks like it's due to the Application Theme and theme inheritance.
Yes I noticed we are both getting a resource not found.
I think if the sherlock search view can't be made to wrap the existing native one or does already. Then a warning or error should be thrown and documentation updated warning that this widget isn't compatible with all android 4+ devices. And people encouraged to detect the os versipn and load the correct class accordingly like I ended up dong (i can post code)
On Tuesday, 11 December 2012, Nathan Wong [email protected] wrote:
Ok, this looks like it's due to the Application Theme and theme inheritance.
— Reply to this email directly or view it on GitHub.
< https://github.com/notifications/beacon/jXIouyFjklbiNRrPH22PBl5IGsA-BCvnFhtrw115pl7J409tw1hYQPHZOj2AlWQ7.gif
If you're using HoloEverywhere: https://github.com/ChristopheVersieux/HoloEverywhere/issues/156
So, out of the blue I suddenly get this error. The app was building and running fine and suddenly this happen.
12-17 17:56:20.901: W/MenuInflater(11863): Cannot instantiate class: com.actionbarsherlock.widget.SearchView
12-17 17:56:20.901: W/MenuInflater(11863): java.lang.reflect.InvocationTargetException
12-17 17:56:20.901: W/MenuInflater(11863): at java.lang.reflect.Constructor.constructNative(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.view.MenuInflater$MenuState.newInstance(MenuInflater.java:488)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.view.MenuInflater$MenuState.setItem(MenuInflater.java:447)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.view.MenuInflater$MenuState.addItem(MenuInflater.java:468)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.view.MenuInflater.parseMenu(MenuInflater.java:190)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.view.MenuInflater.inflate(MenuInflater.java:112)
12-17 17:56:20.901: W/MenuInflater(11863): at com.mondial.thailand.rsa.fragment.MapFragment$SearchActionMode.onCreateActionMode(MapFragment.java:586)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.internal.ActionBarSherlockNative$ActionModeCallbackWrapper.onCreateActionMode(ActionBarSherlockNative.java:233)
12-17 17:56:20.901: W/MenuInflater(11863): at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onCreateActionMode(PhoneWindow.java:2550)
12-17 17:56:20.901: W/MenuInflater(11863): at com.android.internal.app.ActionBarImpl$ActionModeImpl.dispatchOnCreate(ActionBarImpl.java:871)
12-17 17:56:20.901: W/MenuInflater(11863): at com.android.internal.app.ActionBarImpl.startActionMode(ActionBarImpl.java:446)
12-17 17:56:20.901: W/MenuInflater(11863): at android.app.Activity.onWindowStartingActionMode(Activity.java:4881)
12-17 17:56:20.901: W/MenuInflater(11863): at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2256)
12-17 17:56:20.901: W/MenuInflater(11863): at android.app.Activity.startActionMode(Activity.java:4864)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.internal.ActionBarSherlockNative.startActionMode(ActionBarSherlockNative.java:211)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.app.SherlockFragmentActivity.startActionMode(SherlockFragmentActivity.java:47)
12-17 17:56:20.901: W/MenuInflater(11863): at com.mondial.thailand.rsa.fragment.MapFragment.showActionMode(MapFragment.java:576)
12-17 17:56:20.901: W/MenuInflater(11863): at com.mondial.thailand.rsa.fragment.MapFragment.onClick(MapFragment.java:570)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.View.performClick(View.java:4202)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.View$PerformClick.run(View.java:17340)
12-17 17:56:20.901: W/MenuInflater(11863): at android.os.Handler.handleCallback(Handler.java:725)
12-17 17:56:20.901: W/MenuInflater(11863): at android.os.Handler.dispatchMessage(Handler.java:92)
12-17 17:56:20.901: W/MenuInflater(11863): at android.os.Looper.loop(Looper.java:137)
12-17 17:56:20.901: W/MenuInflater(11863): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-17 17:56:20.901: W/MenuInflater(11863): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863): at java.lang.reflect.Method.invoke(Method.java:511)
12-17 17:56:20.901: W/MenuInflater(11863): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-17 17:56:20.901: W/MenuInflater(11863): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-17 17:56:20.901: W/MenuInflater(11863): at dalvik.system.NativeStart.main(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863): Caused by: android.view.InflateException: Binary XML file line #29: Error inflating class <unknown>
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
12-17 17:56:20.901: W/MenuInflater(11863): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.widget.SearchView.<init>(SearchView.java:264)
12-17 17:56:20.901: W/MenuInflater(11863): at com.actionbarsherlock.widget.SearchView.<init>(SearchView.java:252)
12-17 17:56:20.901: W/MenuInflater(11863): ... 30 more
12-17 17:56:20.901: W/MenuInflater(11863): Caused by: java.lang.reflect.InvocationTargetException
12-17 17:56:20.901: W/MenuInflater(11863): at java.lang.reflect.Constructor.constructNative(Native Method)
12-17 17:56:20.901: W/MenuInflater(11863): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-17 17:56:20.901: W/MenuInflater(11863): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
12-17 17:56:20.901: W/MenuInflater(11863): ... 38 more
12-17 17:56:20.901: W/MenuInflater(11863): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01001f a=-1}
12-17 17:56:20.901: W/MenuInflater(11863): at android.content.res.Resources.loadColorStateList(Resources.java:2074)
12-17 17:56:20.901: W/MenuInflater(11863): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
12-17 17:56:20.901: W/MenuInflater(11863): at android.widget.TextView.<init>(TextView.java:775)
12-17 17:56:20.901: W/MenuInflater(11863): at android.widget.TextView.<init>(TextView.java:449)
12-17 17:56:20.901: W/MenuInflater(11863): ... 41 more
R.menu.interactive_map
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:panel="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_search"
android:title="@string/app_name"
android:icon="@android:drawable/ic_menu_search"
android:showAsAction="always"
android:actionViewClass="com.actionbarsherlock.widget.SearchView" />
</menu>
This is placed inside a Fragment. ActionMode, Menu, and MenuInflater are all ABS.
private class SearchActionMode implements ActionMode.Callback{
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
Log.d(TAG, "onCreateActionMode creating inflater");
MenuInflater inflater = new MenuInflater(getActivity());
Log.d(TAG, "onCreateActionMode inflating"); // **Exception thrown after this line.**
inflater.inflate(R.menu.interactive_map, menu);
Log.d(TAG, "onCreateActionMode finding SearchView");
mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
Log.d(TAG, "mSearchView: " + mSearchView);
setupSearchView();
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
Log.d(TAG, "onPrepareActionMode");
mSearchView.requestFocus();
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
Log.d(TAG, "onActionItemClicked");
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
Log.d(TAG, "onDestroyActionMode");
closeTopTray();
closeListView();
}
}
I created an empty project and added just a single line to it to get the error:
SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());
12-17 16:49:56.844: E/AndroidRuntime(12016): FATAL EXCEPTION: main 12-17 16:49:56.844: E/AndroidRuntime(12016): android.view.InflateException: Binary XML file line #29: Error inflating class
12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:606) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView. (SearchView.java:264) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView. (SearchView.java:252) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.example.testsearchview.MainActivity.onCreateOptionsMenu(MainActivity.java:23) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreatePanelMenu(SherlockActivity.java:184) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreateOptionsMenu(SherlockActivity.java:149) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.Activity.onCreatePanelMenu(Activity.java:2444) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:405) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:756) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2852) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.handleCallback(Handler.java:605) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.dispatchMessage(Handler.java:92) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Looper.loop(Looper.java:137) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.ActivityThread.main(ActivityThread.java:4424) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invokeNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invoke(Method.java:511) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 12-17 16:49:56.844: E/AndroidRuntime(12016): at dalvik.system.NativeStart.main(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: java.lang.reflect.InvocationTargetException 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.constructNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:586) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 26 more 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01001f a=-1} 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.Resources.loadColorStateList(Resources.java:2044) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView. (TextView.java:786) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView. (TextView.java:454) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 29 more
Thats what happened to me. I ended up just using the native search view for the modern OS as a work around as it works the same without the pain.
On 17 Dec 2012, at 14:53, Pijus Navickas wrote:
I created an empty project and added just a single line to it to get the error:
SearchView searchView = new SearchView(getSupportActionBar().getThemedContext()); 12-17 16:49:56.844: E/AndroidRuntime(12016): FATAL EXCEPTION: main 12-17 16:49:56.844: E/AndroidRuntime(12016): android.view.InflateException: Binary XML file line #29: Error inflating class 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:606) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView.(SearchView.java:264) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.widget.SearchView.(SearchView.java:252) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.example.testsearchview.MainActivity.onCreateOptionsMenu(MainActivity.java:23) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreatePanelMenu(SherlockActivity.java:184) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.ActionBarSherlock.callbackCreateOptionsMenu(ActionBarSherlock.java:559) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.internal.ActionBarSherlockNative.dispatchCreateOptionsMenu(ActionBarSherlockNative.java:60) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.actionbarsherlock.app.SherlockActivity.onCreateOptionsMenu(SherlockActivity.java:149) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.Activity.onCreatePanelMenu(Activity.java:2444) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:405) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow.invalidatePanelMenu(PhoneWindow.java:756) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:2852) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.handleCallback(Handler.java:605) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Handler.dispatchMessage(Handler.java:92) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.os.Looper.loop(Looper.java:137) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.app.ActivityThread.main(ActivityThread.java:4424) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invokeNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Method.invoke(Method.java:511) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:817) 12-17 16:49:56.844: E/AndroidRuntime(12016): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584) 12-17 16:49:56.844: E/AndroidRuntime(12016): at dalvik.system.NativeStart.main(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: java.lang.reflect.InvocationTargetException 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.constructNative(Native Method) 12-17 16:49:56.844: E/AndroidRuntime(12016): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.view.LayoutInflater.createView(LayoutInflater.java:586) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 26 more 12-17 16:49:56.844: E/AndroidRuntime(12016): Caused by: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f01001f a=-1} 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.Resources.loadColorStateList(Resources.java:2044) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView.(TextView.java:786) 12-17 16:49:56.844: E/AndroidRuntime(12016): at android.widget.TextView.(TextView.java:454) 12-17 16:49:56.844: E/AndroidRuntime(12016): ... 29 more
— Reply to this email directly or view it on GitHub.
Add a test case to the known-bugs project on the dev branch.
Thanks to @esteluk and @Prototik. I fixed it by adding to v14 ofSherlock theme.
<item name="textColorPrimary">@color/abs__primary_text_holo_light</item>
<item name="textColorPrimaryInverse">@color/abs__primary_text_holo_dark</item>
@RobGThai, can you please post an example? Your fix seems to not working on my side. Thanks.
Basically, in res/values-v14/abs__themes.xml
Added those items to Sherlock.__Theme
<style name="Sherlock.__Theme" parent="android:Theme.Holo">
<item name="textColorPrimary">@color/abs__primary_text_holo_light</item>
<item name="textColorPrimaryInverse">@color/abs__primary_text_holo_dark</item>
</style>
Both of those attributes are already defined in the Theme.Sherlock* themes.
@RobGThai, thanks for the snippet. But it doesn't work on my side and I did follow the example code in your first post.