Search in sources :

Example 16 with SearchView

use of android.widget.SearchView in project osm-contributor by jawg.

the class TypeListActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_manage_poi, menu);
    final MenuItem searchItem = menu.findItem(R.id.action_search);
    searchView = (SearchView) searchItem.getActionView();
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            onQueryTextChange(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            typesAdapter.getFilter().filter(newText);
            filterConstraint = newText;
            return true;
        }
    });
    if (!showingTypes) {
        searchView.setVisibility(View.GONE);
    }
    if (showingTypes && !StringUtils.isEmpty(filterConstraint)) {
        searchView.setIconified(false);
        searchView.setQuery(filterConstraint, true);
    }
    return true;
}
Also used : SearchView(android.widget.SearchView) MenuItem(android.view.MenuItem)

Example 17 with SearchView

use of android.widget.SearchView in project AnExplorer by 1hakr.

the class StandaloneActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.activity, menu);
    for (int i = 0; i < menu.size(); i++) {
        final MenuItem item = menu.getItem(i);
        switch(item.getItemId()) {
            default:
                item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
        }
    }
    final MenuItem searchMenu = menu.findItem(R.id.menu_search);
    mSearchView = (SearchView) searchMenu.getActionView();
    mSearchView.setOnQueryTextListener(new OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            mSearchExpanded = true;
            mState.currentSearch = query;
            mSearchView.clearFocus();
            onCurrentDirectoryChanged(ANIM_NONE);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    searchMenu.setOnActionExpandListener(new OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            mSearchExpanded = true;
            updateActionBar();
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            mSearchExpanded = false;
            if (mIgnoreNextCollapse) {
                mIgnoreNextCollapse = false;
                return true;
            }
            mState.currentSearch = null;
            onCurrentDirectoryChanged(ANIM_NONE);
            return true;
        }
    });
    mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {

        @Override
        public boolean onClose() {
            mSearchExpanded = false;
            if (mIgnoreNextClose) {
                mIgnoreNextClose = false;
                return false;
            }
            mState.currentSearch = null;
            onCurrentDirectoryChanged(ANIM_NONE);
            return false;
        }
    });
    return true;
}
Also used : OnQueryTextListener(android.widget.SearchView.OnQueryTextListener) SearchView(android.widget.SearchView) OnActionExpandListener(android.view.MenuItem.OnActionExpandListener) MenuItem(android.view.MenuItem) Point(android.graphics.Point)

Example 18 with SearchView

use of android.widget.SearchView in project SeniorProject by 5731075221-PM.

the class HospitalNearbyFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_hospital_nearby, container, false);
    appBarLayout.setExpanded(true, true);
    // searchView = (SearchView) view.findViewById(R.id.searchNearbyHospital);
    // searchView.setIconifiedByDefault(false);
    // searchView.setIconified(false);
    // searchView.clearFocus();
    // searchView.setQueryHint("ค้นหา");
    // searchView.setOnQueryTextListener(this);
    title = getActivity().findViewById(R.id.textTool);
    title.setText("ค้นหาโรงพยาบาลใกล้เคียง");
    recyclerView = (RecyclerView) view.findViewById(R.id.nearbyHospitalRecyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    adapter = new RecyclerViewAdapter(hosList);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
    adapter.setOnLoadMoreListener(new LoadMore() {

        @Override
        public void onLoadMore() {
            if (hosList.size() <= hospitalList.size()) {
                isLoading = true;
                hosList.add(null);
                adapter.notifyItemInserted(hosList.size() - 1);
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        hosList.remove(hosList.size() - 1);
                        adapter.notifyItemRemoved(hosList.size());
                        // Generating more data
                        int index = hosList.size();
                        int end = index + 10;
                        for (int i = index; i < end; i++) {
                            hosList.add(hospitalList.get(i));
                        }
                        if (isGPS && isNetwork)
                            sortHospital();
                        adapter.notifyDataSetChanged();
                        isLoading = false;
                    // adapter.setLoaded();
                    }
                }, 5000);
            } else {
                Toast.makeText(getActivity(), "Loading data completed", Toast.LENGTH_SHORT).show();
            }
        }
    });
    return view;
}
Also used : Handler(android.os.Handler) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 19 with SearchView

use of android.widget.SearchView in project SeniorProject by 5731075221-PM.

the class SearchSymptomFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_search_symptom, container, false);
    appBarLayout.setExpanded(true, true);
    empty = (TextView) view.findViewById(R.id.textEmpty);
    if (diseaseName.isEmpty())
        empty.setVisibility(View.VISIBLE);
    else
        empty.setVisibility(View.INVISIBLE);
    searchView = (SearchView) view.findViewById(R.id.searchSymptom);
    searchView.setIconifiedByDefault(false);
    searchView.setIconified(false);
    searchView.clearFocus();
    searchView.setQueryHint("ค้นหา");
    searchView.setOnQueryTextListener(this);
    recyclerView = (RecyclerView) view.findViewById(R.id.searchSymptomList);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
    conslayout = (ConstraintLayout) view.findViewById(R.id.searchSymptomLayout);
    empty.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
            return true;
        }
    });
    return view;
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) ImageView(android.widget.ImageView) View(android.view.View) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) MotionEvent(android.view.MotionEvent) Nullable(android.support.annotation.Nullable)

Example 20 with SearchView

use of android.widget.SearchView in project SeniorProject by 5731075221-PM.

the class ShowHospitalByOrder method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_show_by_order, container, false);
    // searchView = (SearchView) view.findViewById(R.id.searchHospitalByOrder);
    // searchView.setIconifiedByDefault(false);
    // searchView.setIconified(false);
    // searchView.clearFocus();
    // searchView.setQueryHint("ค้นหา");
    // searchView.setOnQueryTextListener(this);
    recyclerView = (IndexFastScrollRecyclerView) view.findViewById(R.id.searchHospitalList);
    recyclerView.setAdapter(adapter);
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
    recyclerView.setIndexBarColor("#f9f9f9");
    recyclerView.setIndexBarTextColor("#4d4d4d");
    recyclerView.setIndexBarHighLateTextVisibility(true);
    recyclerView.setIndexbarHighLateTextColor("#4cd29f");
    return view;
}
Also used : DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) SearchView(android.widget.SearchView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) IndexFastScrollRecyclerView(in.myinnos.alphabetsindexfastscrollrecycler.IndexFastScrollRecyclerView) Nullable(android.support.annotation.Nullable)

Aggregations

SearchView (android.widget.SearchView)67 View (android.view.View)35 TextView (android.widget.TextView)30 MenuItem (android.view.MenuItem)26 ImageView (android.widget.ImageView)16 ListView (android.widget.ListView)15 AdapterView (android.widget.AdapterView)14 RecyclerView (android.support.v7.widget.RecyclerView)13 SearchManager (android.app.SearchManager)11 Activity (android.app.Activity)7 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)7 SettingsActivity (com.android.settings.SettingsActivity)7 ViewGroup (android.view.ViewGroup)6 Toolbar (android.widget.Toolbar)6 Intent (android.content.Intent)4 MenuInflater (android.view.MenuInflater)4 RecyclerView (androidx.recyclerview.widget.RecyclerView)4 Nullable (android.support.annotation.Nullable)3 FragmentActivity (android.support.v4.app.FragmentActivity)3 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)3