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


Java OnQueryTextListener類代碼示例

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


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

示例1: onCreateOptionsMenu

import android.widget.SearchView.OnQueryTextListener; //導入依賴的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.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.action_search).getActionView();
    
    searchView.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
        	
			Bundle bundle = new Bundle();
			bundle.putString("query", query);

			Fragment fragment = new SearchFragment();
			fragment.setArguments(bundle);
			FragmentManager fragmentManager = getFragmentManager();
			fragmentManager.beginTransaction().replace(R.id.main_container, fragment).commit();
			return true;
        }
        @Override
        public boolean onQueryTextChange(String newText) {
            return true;
        }
    });
    
    // Assumes current activity is the searchable activity
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setIconifiedByDefault(false); // Do not iconify the widget; expand it by default
            
    return true;
}
 
開發者ID:nmcgill,項目名稱:kluster-android,代碼行數:35,代碼來源:MainActivity.java

示例2: onCreateOptionsMenu

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// TODO Auto-generated method stub
	getMenuInflater().inflate(R.menu.main, menu);
	SearchManager searchManager = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE);
	SearchView searchView =
			(SearchView) menu.findItem(R.id.action_search).getActionView();
	searchView.setQueryHint(getResources().getText(R.string.search_hint));
	searchView.setSearchableInfo(
			searchManager.getSearchableInfo(this.getComponentName()));
	searchView.setOnQueryTextListener(new OnQueryTextListener() {

		@Override
		public boolean onQueryTextSubmit(String query) {
			// TODO Auto-generated method stub
			return false;
		}

		@Override
		public boolean onQueryTextChange(String newText) {
			// TODO Auto-generated method stub
			return false;
		}
	});

	return super.onCreateOptionsMenu(menu);
}
 
開發者ID:linggom,項目名稱:Jahamanga,代碼行數:28,代碼來源:SearchMangaActivity.java

示例3: createSearchQueryListener

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
/**
 * Creates and returns a listener, which allows to start a search query when the user enters
 * text.
 *
 * @return The listener, which has been created, as an instance of the type {@link
 * OnQueryTextListener}
 */
private OnQueryTextListener createSearchQueryListener() {
    return new OnQueryTextListener() {

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

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

    };
}
 
開發者ID:michael-rapp,項目名稱:AndroidAdapters,代碼行數:24,代碼來源:MainActivity.java

示例4: newOnQueryTextListener

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:SearchViewCompatHoneycomb.java

示例5: newOnQueryTextListener

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
public static Object newOnQueryTextListener(final OnQueryTextListenerCompatBridge listener) {
    return new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return listener.onQueryTextSubmit(query);
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return listener.onQueryTextChange(newText);
        }
    };
}
 
開發者ID:GigigoGreenLabs,項目名稱:permissionsModule,代碼行數:14,代碼來源:SearchViewCompatHoneycomb.java

示例6: makeSearchMenuEntry

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
@Override
public MenuItem makeSearchMenuEntry(Menu menu) {
  MenuItem item = menu.add("Search");
  searchView = new SearchView(diskusage);
  origSearchBackground = searchView.getBackground();
  item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  item.setIcon(android.R.drawable.ic_search_category_default);
  item.setActionView(searchView);
  if (searchPattern != null) {
    searchView.setIconified(false);
    searchView.setQuery(searchPattern, false);
  }
  searchView.setOnCloseListener(new OnCloseListener() {
    @Override
    public boolean onClose() {
      Log.d("diskusage", "search closed");
      searchPattern = null;
      diskusage.applyPatternNewRoot(masterRoot, null);
      return false;
    }
  });
  searchView.setOnQueryTextListener(new OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      onQueryTextChange(query);
      return false;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
      Log.d("diskusage", "search query changed to: " + newText);
      searchPattern = newText;
      applyPattern(searchPattern);
      return true;
    }
  });
  return item;
}
 
開發者ID:IvanVolosyuk,項目名稱:diskusage,代碼行數:39,代碼來源:DiskUsageMenuHoneycomb.java

示例7: onCreateOptionsMenu

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
@Override
   public boolean onCreateOptionsMenu(final Menu menu) {
       getMenuInflater().inflate(R.menu.mark, menu);
       mBtRetry = menu.findItem(R.id.bt_lost);
	mSearchBox = menu.findItem(R.id.search);

       mSearchView = (SearchView) mSearchBox.getActionView();
       mSearchView.setQueryHint(getString(R.string.mark_editor_hint));

       mSearchView.setOnSearchClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               setItemsVisibility(menu, mSearchBox, false);
               mSearchView.requestFocus();
           }
       });

	mSearchView.setOnCloseListener(new SearchView.OnCloseListener() {
           @Override
           public boolean onClose() {
               setItemsVisibility(menu, mSearchBox, true);
               return false;    // true = prevent collapse mSearchView
           }
       });

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

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

	return true;
}
 
開發者ID:nextgis,項目名稱:nextgislogger,代碼行數:41,代碼來源:MarkActivity.java

示例8: onCreateOptionsMenu

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	// TODO Auto-generated method stub
	mActivity.getMenuInflater().inflate(R.menu.main, menu);
	SearchManager searchManager = (SearchManager) mActivity.getSystemService(Context.SEARCH_SERVICE);
	SearchView searchView =
			(SearchView) menu.findItem(R.id.action_search).getActionView();
	searchView.setQueryHint(getResources().getText(R.string.search_hint));
	searchView.setSearchableInfo(
			searchManager.getSearchableInfo(mActivity.getComponentName()));
	searchView.setOnQueryTextListener(new OnQueryTextListener() {
		
		@Override
		public boolean onQueryTextSubmit(String query) {
			// TODO Auto-generated method stub
			Intent i = new Intent(mActivity, SearchMangaActivity.class);
			i.putExtra(SearchMangaActivity.ARG_MANGA_KEYWORD, query);
			startActivity(i);
			return false;
		}
		
		@Override
		public boolean onQueryTextChange(String newText) {
			// TODO Auto-generated method stub
			return false;
		}
	});

	super.onCreateOptionsMenu(menu, inflater);
}
 
開發者ID:linggom,項目名稱:Jahamanga,代碼行數:31,代碼來源:MangaListFragment.java

示例9: onCreateOptionsMenu

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

    mSearchView = (SearchView)
        menu.findItem(R.id.search_MenuItem).getActionView();
    mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {
            LOGI("onQueryTextChange newText='" + newText + "'" +
                 " filter='" + getSearchFilter() + "'");
            if (!equalFilters(mLastRequestedFilter, getSearchFilter())) {
                refreshSmsItemAdapter();
            }
            return true;
        }

        public boolean onQueryTextSubmit(String query) {
            LOGI("onQueryTextSubmit query='" + query + "'" +
                 " filter='" + getSearchFilter() + "'");
            if (!equalFilters(mLastRequestedFilter, getSearchFilter())) {
                refreshSmsItemAdapter();
            }
            return true;
        }
    });

    updateOptionsMenu(menu);

    return true;
}
 
開發者ID:alopatindev,項目名稱:smsnenado,代碼行數:32,代碼來源:MainActivity.java

示例10: setOnQueryTextListener

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
public static void setOnQueryTextListener(Object searchView, Object listener) {
    ((SearchView) searchView).setOnQueryTextListener((OnQueryTextListener) listener);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:SearchViewCompatHoneycomb.java

示例11: onQueryTextChange

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
public Disposable onQueryTextChange(final Consumer<? super String> onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
    N.requireNonNull(onNext, "onNext");
    N.requireNonNull(onError, "onError");
    N.requireNonNull(onComplete, "onComplete");

    dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
        @Override
        public void onNext(Object param) {
            @SuppressWarnings("unchecked")
            final String tmp = (String) param;

            if (Fu.isUiThread()) {
                onNext.accept(tmp);
            } else {
                UIExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        onNext.accept(tmp);
                    }
                });
            }
        }
    });

    _view.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            dispatcher.onNext(newText);
            return true;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            // Do nothing.
            return false;
        }
    });

    disposeActions.add(new Runnable() {
        @Override
        public void run() {
            _view.setOnQueryTextListener(null);
        }
    });

    return this;
}
 
開發者ID:landawn,項目名稱:AbacusUtil,代碼行數:48,代碼來源:Observer.java

示例12: onQueryTextSubmit

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
public Disposable onQueryTextSubmit(final Consumer<? super String> onNext, final Consumer<? super Exception> onError, final Runnable onComplete) {
    N.requireNonNull(onNext, "onNext");
    N.requireNonNull(onError, "onError");
    N.requireNonNull(onComplete, "onComplete");

    dispatcher.append(new DispatcherBase<Object>(onError, onComplete) {
        @Override
        public void onNext(Object param) {
            @SuppressWarnings("unchecked")
            final String tmp = (String) param;

            if (Fu.isUiThread()) {
                onNext.accept(tmp);
            } else {
                UIExecutor.execute(new Runnable() {
                    @Override
                    public void run() {
                        onNext.accept(tmp);
                    }
                });
            }
        }
    });

    _view.setOnQueryTextListener(new OnQueryTextListener() {
        @Override
        public boolean onQueryTextChange(String newText) {
            // Do nothing.
            return false;
        }

        @Override
        public boolean onQueryTextSubmit(String query) {
            dispatcher.onNext(query);
            return true;
        }
    });

    disposeActions.add(new Runnable() {
        @Override
        public void run() {
            _view.setOnQueryTextListener(null);
        }
    });

    return this;
}
 
開發者ID:landawn,項目名稱:AbacusUtil,代碼行數:48,代碼來源:Observer.java

示例13: onQueryText

import android.widget.SearchView.OnQueryTextListener; //導入依賴的package包/類
public Disposable onQueryText(final OnQueryTextListener onNext) {
    return onQueryText(onNext, Fu.ON_ERROR_MISSING);
}
 
開發者ID:landawn,項目名稱:AbacusUtil,代碼行數:4,代碼來源:Observer.java

示例14: onCreateOptionsMenu

import android.widget.SearchView.OnQueryTextListener; //導入依賴的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.friends_list, menu);		
	// Associate searchable configuration with the SearchView
    SearchManager searchManager =
           (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView =
            (SearchView) menu.findItem(R.id.menuSearch).getActionView();
    mSearchView.setSearchableInfo(
            searchManager.getSearchableInfo(getComponentName()));	    
    mSearchView.setOnQueryTextListener(new OnQueryTextListener() {			
    		@Override
		public boolean onQueryTextSubmit(String query) {
			return true;
		}
		
		@Override
		public boolean onQueryTextChange(final String newText) {
			LensRocketLogger.i(TAG, "Text: " + newText);
			mCurrentName = newText;
			mBtnAddFriend.setEnabled(true);
			mBtnAddFriend.setVisibility(View.VISIBLE);				
			mAdapter.getFilter().filter(newText, new FilterListener() {					
				@Override
				public void onFilterComplete(int count) {
					if (mAdapter.getCount() > 0) 
						mLvFriends.setVisibility(View.VISIBLE);
					else
						mLvFriends.setVisibility(View.GONE);
				
					if (!mCurrentName.equals("")) {
						mLayoutAddFriend.setVisibility(View.VISIBLE);
					} else {
						mLayoutAddFriend.setVisibility(View.GONE);
					}					
					if (mLensRocketService.getLocalFriendNames().contains(newText))
						mLayoutAddFriend.setVisibility(View.GONE);
				}
			});
			mLblNewFriendName.setText(mCurrentName);								
			return true;
		}
	});		
	return true;
}
 
開發者ID:Microsoft,項目名稱:Android-LensRocket,代碼行數:47,代碼來源:FriendsListActivity.java


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