I am Using AppCompat v21 with toolbar and im developing in Android Studio 0.8.14
If i plug my (4.4) phone into PC via usb and run app the searchview works as it should. I bring up the fragment and press the search icon and it allows me to type text.
However if i assemble release in gradle and install app on my device when i press the search icon nothing happens. Does not initiate the searchview. Here is my code.
My IconsFrag.java
@Override
public void onPrepareOptionsMenu (Menu menu) {
Log.i(FRAG_TAG, "onPrepareOptionsMenu");
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.icon_menu, menu);
MenuItem searchItem = menu.findItem(R.id.search);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = null;
if (searchItem != null) {
searchView = (SearchView) searchItem.getActionView();
}
if (searchView != null) {
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Log.i(FRAG_TAG, "onOptionsItemSelected");
return super.onOptionsItemSelected(item);
}
my module build.gradle
repositories {
mavenLocal()
mavenCentral()
dependencies {
apply plugin: 'maven'
compile 'com.github.gabrielemariotti.cards:library:1.9.1'
compile 'com.nhaarman.listviewanimations:library:2.6.0'
compile 'com.github.gabrielemariotti.changeloglib:library:1.5.2'
compile 'com.shamanland:fab:0.0.5'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.google.android.apps.muzei:muzei-api:+'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.loopj.android:android-async-http:1.4.6'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
compile 'com.daimajia.easing:library:1.0.0@aar'
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
}
maven { url 'http://download.crashlytics.com/maven' }
flatDir{
dirs 'libs'
}
}
Properties props = new Properties()
props.load(new FileInputStream(file(project.property("test.properties"))))
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "source.test.com"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
signingConfigs {
release {
storeFile file(props['keystore'])
storePassword props['keystore.password']
keyAlias props['keyAlias']
keyPassword props['keyPassword']
}
}
buildTypes {
release {
debuggable false
zipAlign true
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
proguardFile file('proguard.txt')
signingConfig signingConfigs.release
}
}
lintOptions {
checkReleaseBuilds true
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:palette-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.crashlytics.android:crashlytics:1.+'
compile 'uk.me.lewisdeane.ldialogs:materialdialog@aar'
}
And here is my menu
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/search"
android:title="@string/search"
android:icon="@drawable/app_ic_menu_search"
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView" />
</menu>
0 comments:
Post a Comment