当前位置: 首页>>代码示例>>Java>>正文


Java SearchView.setSearchableInfo方法代码示例

本文整理汇总了Java中android.widget.SearchView.setSearchableInfo方法的典型用法代码示例。如果您正苦于以下问题:Java SearchView.setSearchableInfo方法的具体用法?Java SearchView.setSearchableInfo怎么用?Java SearchView.setSearchableInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.SearchView的用法示例。


在下文中一共展示了SearchView.setSearchableInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(true); // Do not iconify the widget; expand it by default

    searchView.setQueryHint(getResources().getString(R.string.search_hint));

    return true;
}
 
开发者ID:JamesJose7,项目名称:GithubProject,代码行数:18,代码来源:MainActivity.java

示例2: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  SearchView searchView = new SearchView(this);
  searchView.setSearchableInfo(((SearchManager) getSystemService(Context.SEARCH_SERVICE)).getSearchableInfo(getComponentName()));
  searchView.setOnQueryTextListener(this);

  menu.add(android.R.string.search_go)
    .setIcon(android.R.drawable.ic_menu_search)
    .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW + MenuItem.SHOW_AS_ACTION_ALWAYS)
    .setActionView(searchView)
    .setOnActionExpandListener(this);

  if (mShowTint) {
    MenuItem item = menu.add(R.string.wc_tint);
    item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    item.setActionView(R.layout.ab_color_btn);
    ColorButton cb = (ColorButton) item.getActionView().findViewById(R.id.btn_tint);
    cb.setColor(mAdapter.mColorFilter);
    cb.setOnColorChangeListener(this, true);
  }
  return true;
}
 
开发者ID:sunnygoyal,项目名称:PowerToggles,代码行数:23,代码来源:IconPackPicker.java

示例3: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

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

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

        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });
}
 
开发者ID:dream83619,项目名称:GoogleBookReader-android,代码行数:24,代码来源:BookListFragment.java

示例4: configureSearchWidget

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public void configureSearchWidget(
    Activity activity, MenuItem menuItem, final TrackController trackController) {
  SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
  SearchView searchView = (SearchView) menuItem.getActionView();
  searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
  searchView.setQueryRefinementEnabled(true);
  searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
    
      @Override
    public void onFocusChange(View v, boolean hasFocus) {
        // Hide and show trackController when search widget has focus/no focus
        if (trackController != null) {
          if (hasFocus) {
            trackController.hide();
          } else {
            trackController.show();
          }
        }        
    }
  });
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:23,代码来源:Api11Adapter.java

示例5: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	getMenuInflater().inflate(R.menu.activity_main, menu);

       // Associate searchable configuration with the SearchView
       SearchManager searchManager =
               (SearchManager) getSystemService(Context.SEARCH_SERVICE);
       searchMenuItem = menu.findItem(R.id.search);
       final SearchView searchView =
               (SearchView) searchMenuItem.getActionView();
       searchView.setSearchableInfo(
               searchManager.getSearchableInfo(getComponentName()));
       searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
           @Override
           public void onFocusChange(View view, boolean queryTextFocused) {
               if(!queryTextFocused) {
                   searchMenuItem.collapseActionView();
                   searchView.setQuery("", false);
               }
           }
       });

	return true;
}
 
开发者ID:danielebufarini,项目名称:Reminders,代码行数:25,代码来源:Reminders.java

示例6: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.share_menu, menu);

    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE);

    if (searchItem != null) {
        mSearchView = (SearchView) searchItem.getActionView();
    }

    if (mSearchView != null) {
        mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        mSearchView.setIconified(false);
        mSearchView.setQueryHint(getString(R.string.search_view_hint));
        mSearchView.setMaxWidth(getResources().getDimensionPixelOffset(R.dimen.BU_22));
    }
    setListenerForSearchView();
    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:paladin952,项目名称:Movie-Time-Spent,代码行数:22,代码来源:MainActivity.java

示例7: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);

    SearchManager mSearchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView();

    mSearchView.setSearchableInfo(mSearchManager.getSearchableInfo(getComponentName()));
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
       @Override
       public boolean onQueryTextSubmit(String query) {
           mAdapter.getFilter().filter(query);
           return false;
       }

       @Override
       public boolean onQueryTextChange(String newText) {
           mAdapter.getFilter().filter(newText);
           return false;
       }
    });

    return true;
}
 
开发者ID:MrDoomy,项目名称:OverFlow,代码行数:26,代码来源:ContactActivity.java

示例8: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu items for use in the action bar
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.main_activity_actions, menu);

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

	searchView.setSearchableInfo(searchManager
			.getSearchableInfo(new ComponentName(this,
					ChannelSearchActivity.class)));
	searchView.setIconifiedByDefault(false);
	searchView.setSubmitButtonEnabled(true);

	return super.onCreateOptionsMenu(menu);
}
 
开发者ID:guglielmino,项目名称:pushetta-android-app,代码行数:20,代码来源:MainActivity.java

示例9: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu){

    MenuInflater inflater = getMenuInflater();
    inflater.inflate (R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchItem = menu.findItem(R.id.search_bar);

    SearchView searchView = (SearchView) searchItem.getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.setSubmitButtonEnabled(false);
    searchView.setOnQueryTextListener(this);

    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:Shaderboy,项目名称:V-Scan,代码行数:18,代码来源:Lookup.java

示例10: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.options_menu, menu);
  // Associate searchable configuration with the SearchView
  SearchManager searchManager =
      (SearchManager) getSystemService(Context.SEARCH_SERVICE);
  searchView = (SearchView) menu.findItem(R.id.search).getActionView();
  searchView.setSearchableInfo(
      searchManager.getSearchableInfo(getComponentName()));
  searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
  searchView.onActionViewExpanded();
  return true;
}
 
开发者ID:charlesng,项目名称:SampleAppArch,代码行数:15,代码来源:ShoppingActivity.java

示例11: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.database_opened, menu);
    getMenuInflater().inflate(R.menu.main, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    searchMenuItem = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false);
    searchView.requestFocusFromTouch();
    return true;
}
 
开发者ID:RyuzakiKK,项目名称:NoteCrypt,代码行数:14,代码来源:MainActivity.java

示例12: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(false);
    }
    
    return true;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:15,代码来源:WordActivity.java

示例13: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){
        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
        searchView.setIconifiedByDefault(false);
    }

    return true;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:15,代码来源:SearchableDictionary.java

示例14: onCreateOptionsMenu

import android.widget.SearchView; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.login_display, menu);
    // Associate searchable configuration with the SearchView
    SearchManager searchManager =
            (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView =
            (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setSearchableInfo(
            searchManager.getSearchableInfo(getComponentName()));
    return true;
}
 
开发者ID:movixdev,项目名称:movix,代码行数:13,代码来源:LoginDisplayActivity.java

示例15: onCreateView

import android.widget.SearchView; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.search_users_groups_layout, container, false);

    // Get the SearchView and set the searchable configuration
    SearchView searchView = (SearchView) view.findViewById(R.id.searchView);
    SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
    searchView.setSearchableInfo(searchManager.getSearchableInfo(
            getActivity().getComponentName())   // assumes parent activity is the searchable activity
    );
    searchView.setIconifiedByDefault(false);    // do not iconify the widget; expand it by default

    searchView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); // avoid fullscreen with softkeyboard

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Log_OC.v(TAG, "onQueryTextSubmit intercepted, query: " + query);
            return true;    // return true to prevent the query is processed to be queried;
            // a user / group will be picked only if selected in the list of suggestions
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;   // let it for the parent listener in the hierarchy / default behaviour
        }
    });

    return view;
}
 
开发者ID:skymania,项目名称:Cirrus,代码行数:36,代码来源:SearchShareesFragment.java


注:本文中的android.widget.SearchView.setSearchableInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。