android:layout_height="wrap_content"
android:src="@drawable/ic_swap_horiz_black_24dp" />
+ <android.support.design.widget.FloatingActionButton
+ android:id="@+id/floatSearchButton"
+ android:layout_toLeftOf="@+id/floatSwapButton"
+ android:layout_alignParentBottom="true"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_search_black_24dp" />
+
<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
import android.preference.PreferenceManager;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
+import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
}
});
+ final FloatingActionButton floatSearchButton = (FloatingActionButton)findViewById(R.id.floatSearchButton);
+ floatSearchButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ if (!searchView.hasFocus()) {
+ searchView.requestFocus();
+ }
+ if (searchView.getQuery().toString().length() > 0) {
+ searchView.setQuery("", false);
+ }
+ showKeyboard();
+ searchView.setIconified(false);
+ }
+ });
+
// Set the search text from the intent, then the saved state.
String text = getIntent().getStringExtra(C.SEARCH_TOKEN);
if (savedInstanceState != null) {
}
currentSearchOperation = new SearchOperation(text, index);
searchExecutor.execute(currentSearchOperation);
+ ((FloatingActionButton)findViewById(R.id.floatSearchButton)).setImageResource(text.length() > 0 ? R.drawable.ic_clear_black_24dp : R.drawable.ic_search_black_24dp);
}
// --------------------------------------------------------------------------