I want to create search view with custom action bar same as to search view in Action-bar. I don't know how to do this.I surfing on the net but most of the result will show the search view with Action-bar not custom Action-bar.But i want to add Search view on my custom Action Bar.Can someone help me .
Here is my custom Action Bar code
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.all_post);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
dbhelper = new MyDbHelper(this);
dbhelper.onOpen(db);
Intent intent = new Intent(CustomActionActivity.this, MyService.class);
startService(intent);
ActionBar mActionBar = getSupportActionBar();
LayoutInflater mInflater = LayoutInflater.from(this);
View mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);
ImageView imgSearchBtn = (ImageView)mCustomView.findViewById(R.id.imgSearchButton);
imgSearchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("Click on ", " Searchview !!!! ");
}
});
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.setDisplayShowCustomEnabled(true);
mActionBar.setCustomView(mCustomView);
Toolbar parent =(Toolbar) mCustomView.getParent();
parent.setContentInsetsAbsolute(0, 0);
}
I want to call search view on button click with collapse and expand function.
ImageView imgSearchBtn = (ImageView)mCustomView.findViewById(R.id.imgSearchButton);
imgSearchBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("Click on ", " Searchview !!!! ");
}
});
Thanks .