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


Java SearchView.setOnQueryTextListener方法代碼示例

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


在下文中一共展示了SearchView.setOnQueryTextListener方法的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 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

示例3: 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) {
            Intent intent = new Intent("Msg_KeyWord");
            intent.putExtra("keyWord", query);
            sendBroadcast(intent);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {

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

示例4: 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

示例5: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);
    MenuItem search = menu.findItem(R.id.search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override public boolean onQueryTextSubmit(String query) {
            getSupportActionBar().setSubtitle("found: "+mAdapter.getItemCount());
            return true;
        }
        @Override public boolean onQueryTextChange(String newText) {
            if (mAdapter != null) {
                mAdapter.getFilter().filter(newText);
            }
            return true;
        }
    });
    menu.findItem(R.id.action_settings).setIntent(new Intent(this,SettingsActivity.class));
    return true;
}
 
開發者ID:AlexeyZatsepin,項目名稱:CP-Tester,代碼行數:21,代碼來源:MainActivity.java

示例6: setupSearchView

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
private void setupSearchView(SearchView searchView) {
    searchView.setIconifiedByDefault(false);

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    if (searchManager != null) {
        SearchableInfo searchableInfo = searchManager.getSearchableInfo(getComponentName());
        searchView.setSearchableInfo(searchableInfo);
    }

    searchView.setOnQueryTextListener(this);
    searchView.requestFocus();

    searchView.setMaxWidth(Integer.MAX_VALUE);
}
 
開發者ID:Vavassor,項目名稱:Tusky,代碼行數:15,代碼來源:SearchActivity.java

示例7: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.menu_search, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getString(R.string.search_hint));
    searchView.setIconifiedByDefault(false);
    ImageView search_mag_icon = (ImageView) searchView.findViewById(R.id.search_mag_icon);
    search_mag_icon.setImageResource(0);
    LinearLayout search_plate = (LinearLayout) searchView.findViewById(R.id.search_plate);
    search_plate.setBackgroundColor(Color.TRANSPARENT);
    searchView.setOnQueryTextListener(mQueryListener);
}
 
開發者ID:XYScience,項目名稱:StopApp,代碼行數:15,代碼來源:AppListFragment.java

示例8: 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.toolbar_default_menu_filechooser, menu);

    // Get the SearchView and set the searchable configuration
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchMenuItem = menu.findItem(R.id.action_search);
    mSearchView = (SearchView)mSearchMenuItem.getActionView();
    // Assumes current activity is the searchable activity
    mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    //searchView.setSubmitButtonEnabled(true);
    mSearchView.setOnQueryTextListener(this);
    return true;
}
 
開發者ID:adityak368,項目名稱:Android-FileBrowser-FilePicker,代碼行數:16,代碼來源:FileChooser.java

示例9: onCreateOptionsMenu

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

    final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getResources().getString(R.string.search_movies_tv_shows_people));

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (!NetworkConnection.isConnected(MainActivity.this)) {
                Toast.makeText(MainActivity.this, R.string.no_network, Toast.LENGTH_SHORT).show();
                return true;
            }
            Intent intent = new Intent(MainActivity.this, SearchActivity.class);
            intent.putExtra(Constant.QUERY, query);
            startActivity(intent);
            searchMenuItem.collapseActionView();
            return true;
        }

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

    return true;
}
 
開發者ID:hitanshu-dhawan,項目名稱:PopCorn,代碼行數:31,代碼來源:MainActivity.java

示例10: onCreateOptionsMenu

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

    getMenuInflater().inflate(R.menu.menu_activity_home, menu);

    //init search in the toolbar
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

    //listener for click in search button
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            startActivity(new Intent(HomeActivity.this, SearchActivity.class)
                    .putExtra(AppConstants.General.SEARCH_TEXT, query));
            return true;
        }

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

    return true;
}
 
開發者ID:fekracomputers,項目名稱:QuranAndroid,代碼行數:28,代碼來源:HomeActivity.java

示例11: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_select_file, menu);
    mSearchViewMenuItem = menu.findItem(R.id.im_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchViewMenuItem);
    mSearchView.setIconifiedByDefault(true);
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setSubmitButtonEnabled(false);
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:11,代碼來源:SelectFileActivity.java

示例12: onCreateOptionsMenu

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

    SearchView searchView = (SearchView) menu.findItem(R.id.contacts_search).getActionView();
    searchView.setOnQueryTextListener(this);

    return true;
}
 
開發者ID:gvinciguerra,項目名稱:custode,代碼行數:11,代碼來源:ContactsPickerActivity.java

示例13: onCreate

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    mTagFlowLayout = (TagFlowLayout) findViewById(R.id.tag_flow_layout);
    mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
    mHintText = (TextView) findViewById(R.id.hint_text);
    mTagLayout = (LinearLayout) findViewById(R.id.tag_layout);
    mFragmentContainer = (FrameLayout) findViewById(R.id.fragment_container);
    mSearchView = (SearchView) findViewById(R.id.search_view);
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            mFragmentContainer.setVisibility(View.GONE);
            searchData(query);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    mExitButton = (Button) findViewById(R.id.exit_button);
    mExitButton.setOnClickListener(this);
    mFragmentManager = getSupportFragmentManager();
    loadData();
}
 
開發者ID:KnowledgeBegger,項目名稱:MyEyepetizer,代碼行數:29,代碼來源:SearchActivity.java

示例14: onCreateOptionsMenu

import android.support.v7.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search_menu, menu);
    MenuItem search = menu.findItem(R.id.search_menu);
    searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.onActionViewExpanded();
    searchView.setOnQueryTextListener(this);
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:htqqdd,項目名稱:music_player,代碼行數:10,代碼來源:searchActivity.java

示例15: onCreateOptionsMenu

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

	// search view
	final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
	final SearchView searchView = (SearchView) searchMenuItem.getActionView();
	searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener()
	{
		@Override
		public boolean onQueryTextSubmit(final String query)
		{
			searchView.clearFocus();
			searchView.setQuery("", false);
			tryStartTreebolic(query);
			return true;
		}

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

	return true;
}
 
開發者ID:1313ou,項目名稱:Treebolic,代碼行數:30,代碼來源:MainActivity.java


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