我正在使用Holoeverywhere并尝试在我的onCreateOptionsMenu方法中获取ActionView和ActionProvider,但是gradle抱怨在MenuItemCompat中找不到getActionProvider和getActionView方法符号。这听起来类似于Gradle and Android v7 compat issue,但没有一个解决方案有效。有什么想法吗?
...theysaidwhat\deck\DeckEditFragment.java:133: error: cannot find symbol
actionProvider = (DeckFilterActionProvider) MenuItemCompat.getActionProvider(filterItem);
^
symbol: method getActionProvider(MenuItem)
location: class MenuItemCompat
...\theysaidwhat\deck\DeckEditFragment.java:139: error: cannot find symbol
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
^
symbol: method getActionView(MenuItem)
location: class MenuItemCompat
片段
public class DeckEditFragment extends org.holoeverywhere.app.Fragment implements
LoaderCallbacks<Cursor> {
...
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.activity_deck_manager_menu, menu);
MenuItem filterItem = menu.findItem(R.id.deckFilter);
actionProvider = (DeckFilterActionProvider) MenuItemCompat.getActionProvider(filterItem);
actionProvider.adapter = adapter;
MenuItem searchItem = menu.findItem(R.id.action_search);
final ContentResolver resolver = getActivity().getContentResolver();
SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
菜单
<item
android:id="@+id/deckFilter"
android:showAsAction="always"
android:title="filters"
android:actionProviderClass="com.howbig.theysaidwhat.deck.DeckFilterActionProvider"/>
<item
android:id="@+id/action_search"
android:actionViewClass="android.support.v7.widget.SearchView"
android:icon="@drawable/ic_action_search"
android:showAsAction="always"
android:title="Search"/>
</menu>
gradle这个
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':baseGameUtils')
compile project(':holoEverywhereAddonPreferences')
compile project(':holoEverywhereLibrary')
compile project(':volley')
compile 'com.google.android.gms:play-services:+'
compile files('libs/android-sqlite-asset-helper.jar')
compile files('libs/crittercism_v3_2_0_sdkonly.jar')
}