當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchView類代碼示例

本文整理匯總了Java中android.support.v7.widget.SearchView的典型用法代碼示例。如果您正苦於以下問題:Java SearchView類的具體用法?Java SearchView怎麽用?Java SearchView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SearchView類屬於android.support.v7.widget包,在下文中一共展示了SearchView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    /*簡單查詢*/
    final MenuItem item = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(item);

    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            paraMap.put("keyWord", query);
            showLoading();
            refresh = true;
            presenter.getData(1, SIZE, paraMap);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {

            return false;
        }
    });
    return true;
}
 
開發者ID:liuyongfeng90,項目名稱:JKCloud,代碼行數:26,代碼來源:OpportunityListActivity.java

示例2: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_menu, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search_btn).getActionView();

    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
    searchView.setMaxWidth(Integer.MAX_VALUE);
    searchView.requestFocus(1);
    //searchView.setSubmitButtonEnabled(true);


    return true;
}
 
開發者ID:Socialate,項目名稱:furry-sniffle,代碼行數:20,代碼來源:MainActivity.java

示例3: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if(loaderId == DELETED_LOADER_ID){
        inflater.inflate(R.menu.menu_fragment_bin, menu);
    }

    // Place an action bar item for searching.
    MenuItem item = menu.add("Search");
    item.setIcon(R.drawable.ic_search_white_24dp);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM|MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchView = new SearchView(myActivity);
    searchView.setMaxWidth(Integer.MAX_VALUE);

    // Set searchbox text to white
    EditText searchEditText = (EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
    searchEditText.setTextColor(ContextCompat.getColor(getContext(), R.color.white));
    searchEditText.setHintTextColor(ContextCompat.getColor(getContext(), R.color.white));

    searchView.setOnQueryTextListener(this);
    item.setActionView(searchView);
    super.onCreateOptionsMenu(menu, inflater);

}
 
開發者ID:danlls,項目名稱:Todule-android,代碼行數:25,代碼來源:ToduleListFragment.java

示例4: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    final MenuItem item = menu.findItem(R.id.action_search);
    SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(item);
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if (shouldShowFAQ)
                ((Searchable) currentFragment).setSearchText(newText);
            return true;
        }
    });
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:w568w,項目名稱:fuckView,代碼行數:22,代碼來源:MainActivity.java

示例5: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.questions, menu);

  // Setup search widget in action bar
  SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
  searchView.setQueryHint(getString(R.string.search_hint));
  searchView.setImeOptions(EditorInfo.IME_ACTION_DONE);

  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override public boolean onQueryTextSubmit(String query) {
      return false;
    }

    @Override public boolean onQueryTextChange(String newText) {
      presenter.search(newText);
      return true;
    }
  });

  return true;
}
 
開發者ID:quangctkm9207,項目名稱:mvp-android-arch-component,代碼行數:22,代碼來源:QuestionsActivity.java

示例6: buildMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean buildMenu(Menu menu, @NonNull MenuInflater inflater) {

    inflater.inflate(R.menu.swap_next_search, menu);
    MenuItem nextMenuItem = menu.findItem(R.id.action_next);
    int flags = MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT;
    MenuItemCompat.setShowAsAction(nextMenuItem, flags);
    nextMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            getActivity().onAppsSelected();
            return true;
        }
    });

    SearchView searchView = new SearchView(getActivity());

    MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    MenuItemCompat.setActionView(searchMenuItem, searchView);
    MenuItemCompat.setShowAsAction(searchMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);

    searchView.setOnQueryTextListener(this);
    return true;
}
 
開發者ID:uhuru-mobile,項目名稱:mobile-store,代碼行數:25,代碼來源:SelectAppsView.java

示例7: setupSearchView

import android.support.v7.widget.SearchView; //導入依賴的package包/類
private void setupSearchView(Menu menu) {
    ActionBar actionBar = getSupportActionBar();
    Context context = actionBar != null ? actionBar.getThemedContext() : this;
    SearchView searchView = new SearchView(context);
    searchView.setIconifiedByDefault(false);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String queryText) {
            mEasyRecycleAdapter.setItems(new ArrayList<PointOfInterest>());
            if (queryText.length() > 0) {
                getAutocompleteResults(queryText);
            } else {
                mSubscriptions.unsubscribe();
                mProgressBar.setVisibility(View.GONE);
            }
            return false;
        }
    });
    searchView.requestFocus();
    menu.findItem(R.id.action_search).setActionView(searchView);
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:27,代碼來源:SearchActivity.java

示例8: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.project_menu, menu);

    sortByName = menu.findItem(R.id.menu_sort_by_name);
    sortByTimeSpent = menu.findItem(R.id.menu_sort_by_time);

    sortByName.setChecked(isSortedByName);
    sortByTimeSpent.setChecked(isSortedByName);

    sortData();

    final MenuItem searchItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setQueryHint(context.getString(R.string.search_hint));
    searchView.setOnQueryTextListener(this);
}
 
開發者ID:Protino,項目名稱:CodeWatch,代碼行數:19,代碼來源:ProjectsFragment.java

示例9: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    try {
        // inflate the menu items for use in the action bar
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_main_actionbar, menu);

        // Associate searchable configuration with the SearchView
        SearchManager searchManager =
                (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        searchView =
                (SearchView) menu.findItem(R.id.menu_search).getActionView();
        searchView.setSearchableInfo(
                searchManager.getSearchableInfo(getComponentName()));

    }catch(Exception ex){
        LogHelper.e(LOG_TAG, ex.getMessage());
    }finally {
        return super.onCreateOptionsMenu(menu);

    }
}
 
開發者ID:malah-code,項目名稱:Open-Quran-Radio,代碼行數:23,代碼來源:MainActivity.java

示例10: onCreateView

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_search_bookmarks, container, false);

    initViews(view);

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            presenter.loadResults(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            presenter.loadResults(newText);
            return true;
        }
    });

    return  view;
}
 
開發者ID:makezhao,項目名稱:LianXiZhihu,代碼行數:24,代碼來源:SearchFragment.java

示例11: setupSearchView

import android.support.v7.widget.SearchView; //導入依賴的package包/類
private void setupSearchView() {
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            adapter.getFilter().filter(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            if(searchView.getQuery().length() == 0) {
                adapter.getFilter().filter("");
            }
            return true;
        }
    });
}
 
開發者ID:Zhuinden,項目名稱:realm-helpers,代碼行數:18,代碼來源:MainActivity.java

示例12: onPrepareOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {

  boolean res = super.onPrepareOptionsMenu(menu);

  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      getWebViewCoordinator().onQueryByText(query);
      return true;
    }

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

  return res;
}
 
開發者ID:azmedien,項目名稱:kolibri-android,代碼行數:24,代碼來源:PrototypeActivity.java

示例13: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.filter_menu, menu); // inflate the filter


    MenuItem searchViewItem = menu.findItem(R.id.filter_keyword);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            filter.filter("K:" + searchView.getQuery());
            searchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            filter.filter("K:" + searchView.getQuery());
            return false;
        }
    });


    return true;
}
 
開發者ID:CMPUT301W17T08,項目名稱:Moodr,代碼行數:27,代碼來源:Profile.java

示例14: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.latest_menu, menu);
    getMenuInflater().inflate(R.menu.filter_menu, menu);

    MenuItem searchViewItem = menu.findItem(R.id.filter_keyword);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            filter.filter("K:" + searchView.getQuery());
            searchView.clearFocus();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            filter.filter("K:" + searchView.getQuery());
            return false;
        }
    });
    return true;
}
 
開發者ID:CMPUT301W17T08,項目名稱:Moodr,代碼行數:24,代碼來源:LatestActivity.java

示例15: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.nav, menu);

        SearchManager searchManager = (SearchManager)
                getSystemService(Context.SEARCH_SERVICE);

        searchMenuItem = menu.findItem(R.id.action_search);
        searchView = (SearchView) searchMenuItem.getActionView();

        searchView.setSearchableInfo(searchManager.
                getSearchableInfo(getComponentName()));
        searchView.setSubmitButtonEnabled(true);

    return true;
}
 
開發者ID:doljko,項目名稱:youth-health,代碼行數:18,代碼來源:MainActivity.java


注:本文中的android.support.v7.widget.SearchView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。