Reputation: 9079
I have created my own search view as below
public class MySearchView extends SearchView {
public MySearchView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
// The normal SearchView doesn't clear its search text when
// collapsed, so we will do this for it.
@Override
public void onActionViewCollapsed() {
setQuery("", false);
super.onActionViewCollapsed();
}
}
When i have to create an item of this search View i must pass the context like getActivity()
But since ActionBarActivity does not have getActivity(), what should I pass
Upvotes: 0
Views: 3445
Reputation: 21
Inside the ActionBarActivity extended class, you can access the context by calling the method: getApplicationContext().
Hope this helps! Nick
Upvotes: 2