I have an imageView. When i click image, i am hidding image and enabling searchview in expanded. But problem is close icon is not visible. How to make close icon visible when searchview in expanded form?
Here is my piece of code:
public class HomeActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
search = (SearchView) findViewById(R.id.search);
searchImage=(ImageView) findViewById(R.id.search_image);
searchImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
search.setVisibility(View.VISIBLE);
search.setIconifiedByDefault(false); // here i am disabling default icon
searchImage.setVisibility(View.GONE);
}
});
//This function not works as close icon not visible.
search.setOnCloseListener(new OnCloseListener() {
@Override
public boolean onClose() {
searchImage.setVisibility(View.VISIBLE);
return false;
}
});
Here is screenshot where close icon at top right not visible:
the back option will display when you use[Complete concept about SearchView]
and use
If you want to get Query String use this:
Dont forget to add this code in your Manifest Activity
If you want you can add click listener on
closeButton
Try this
Use the attribute
app:closeIcon="@drawable/ic_my_close_icon"
in yourSearchView
orandroid.support.v7.widget.SearchView
Use
xmlns:app="http://schemas.android.com/apk/res-auto"