List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_SEARCH
int IME_ACTION_SEARCH
To view the source code for android.view.inputmethod EditorInfo IME_ACTION_SEARCH.
Click Source Link
From source file:org.profeda.dictionary.SearchActivity.java
/** * Called when the activity is first created. *//*from w w w. j av a 2 s. c o m*/ @Override public void onCreate(Bundle savedInstanceState) { final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(SearchActivity.this); if (pref.getBoolean("show_changelog", true) == true) { MessageBox.showChangeLog(this); } loadDictionaries(pref); if (pref.getBoolean("p_invert_colors", false) == true) { setTheme(R.style.Light); } else { setTheme(R.style.Dark); } super.onCreate(savedInstanceState); setContentView(R.layout.main); dict = new Dict(this, pref.getString("dictFile", null)); updateTitleBar(); readMRU(); final EditText searchbox = (EditText) findViewById(R.id.searchbox); final Button dictselectbutton = (Button) findViewById(R.id.dictselectbutton); final ListView listview = (ListView) findViewById(R.id.contentlist); listview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView l, View v, int position, long id) { ListAdapter la = ((ListView) l).getAdapter(); if (la instanceof GenericStringAdapter) { final String data = (String) la.getItem(position); if (data.startsWith("> ")) { searchbox.setText(data.substring(2)); doSearch(true); } } else if (la instanceof DictListAdapter) { final String[] data = (String[]) la.getItem(position); final List<Dict> langs = Dict.searchForLanguage(SearchActivity.this, dict.toLang, null); String[] menu = new String[langs.size() + 1]; menu[0] = getString(R.string.copy_translation_to_clipboard); for (int i = 1; i < menu.length; i++) menu[i] = String.format(getString(R.string.search_translation_in_language), langs.get(i - 1).toLang); Matcher m = Pattern.compile("<b>(.*)<\\/b>.*").matcher(data[1]); if (!m.matches()) return; final String translation = m.group(1).trim(); new AlertDialog.Builder(SearchActivity.this).setIcon(android.R.drawable.ic_dialog_info) .setTitle(translation).setItems(menu, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { switch (arg1) { case 0: ClipboardManager cm = (ClipboardManager) getSystemService( CLIPBOARD_SERVICE); cm.setText(translation); break; default: dict = langs.get(arg1 - 1); readMRU(); updateTitleBar(); searchbox.setText(translation); doSearch(true); } } }).show(); } } }); searchbox.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_DONE || event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) { doSearch(true); return true; } else { return false; } } }); final Drawable deleteIcon = getResources().getDrawable(R.drawable.textbox_clear); //deleteIcon.setBounds(0, 0, deleteIcon.getIntrinsicWidth(), deleteIcon.getIntrinsicHeight()); deleteIcon.setBounds(0, 0, 51, 30); // wtf??? die Zahlen sind empirisch ermittelt... ab right>=52 springt die hhe des editText searchbox.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { searchbox.setCompoundDrawables(null, null, s.toString().equals("") ? null : deleteIcon, null); //searchbox.setCompoundDrawablesWithIntrinsicBounds(null, null, s.toString().equals("") ? null : deleteIcon, null); searchbox.setCompoundDrawablePadding(0); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { if (enableLivesearch && s.length() > 1 && dict.filePrefix != null && dictSearchInAction == false) { DictionarySearcher ds = new DictionarySearcher(); ds.targetList = (ListView) findViewById(R.id.contentlist); ds.execute(dict.filePrefix, s.toString()); } if (s.length() == 0) { displayMRU(); } } }); //searchbox.setCompoundDrawables(null, null, deleteIcon, null); searchbox.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (searchbox.getCompoundDrawables()[2] == null) { return false; } if (event.getAction() != MotionEvent.ACTION_UP) { return false; } if (event.getX() > searchbox.getWidth() - searchbox.getPaddingRight() - deleteIcon.getIntrinsicWidth()) { searchbox.setText(""); searchbox.setCompoundDrawables(null, null, null, null); } return false; } }); dictselectbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { selectDictionary(); } }); ((Button) findViewById(R.id.dictswapbutton)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final List<Dict> langs = Dict.searchForLanguage(SearchActivity.this, dict.toLang, dict.fromLang); if (langs.size() > 0) { dict = langs.get(0); readMRU(); updateTitleBar(); searchbox.setText(""); } else { MessageBox.alert(SearchActivity.this, getString(R.string.no_reverse_dict_found)); } } }); }
From source file:it.reyboz.bustorino.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.stopsDB = new StopsDB(getApplicationContext()); this.userDB = new UserDB(getApplicationContext()); setContentView(R.layout.activity_main); busStopSearchByIDEditText = (EditText) findViewById(R.id.busStopSearchByIDEditText); busStopSearchByNameEditText = (EditText) findViewById(R.id.busStopSearchByNameEditText); busStopNameTextView = (TextView) findViewById(R.id.busStopNameTextView); progressBar = (ProgressBar) findViewById(R.id.progressBar); howDoesItWorkTextView = (TextView) findViewById(R.id.howDoesItWorkTextView); hideHintButton = (Button) findViewById(R.id.hideHintButton); resultsListView = (ListView) findViewById(R.id.resultsListView); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout); floatingActionButton = (FloatingActionButton) findViewById(R.id.floatingActionButton); if (floatingActionButton != null) { floatingActionButton.attachToListView(resultsListView); }// w w w. j a v a 2 s . com busStopSearchByIDEditText.setSelectAllOnFocus(true); busStopSearchByIDEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // IME_ACTION_SEARCH alphabetical option if (actionId == EditorInfo.IME_ACTION_SEARCH) { onSearchClick(v); return true; } return false; } }); busStopSearchByNameEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { // IME_ACTION_SEARCH alphabetical option if (actionId == EditorInfo.IME_ACTION_SEARCH) { onSearchClick(v); return true; } return false; } }); // Called when the layout is pulled down swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { handler.post(refreshing); } }); /** * @author Marco Gagino!!! */ swipeRefreshLayout.setColorSchemeColors(R.color.blue_500, R.color.orange_500); // setColorScheme is deprecated, setColorSchemeColors isn't setSearchModeBusStopID(); //---------------------------- START INTENT CHECK QUEUE ------------------------------------ // Intercept calls from URL intent boolean tryedFromIntent = false; String busStopID = null; String busStopDisplayName = null; Uri data = getIntent().getData(); if (data != null) { busStopID = getBusStopIDFromUri(data); tryedFromIntent = true; } // Intercept calls from other activities if (!tryedFromIntent) { Bundle b = getIntent().getExtras(); if (b != null) { busStopID = b.getString("bus-stop-ID"); busStopDisplayName = b.getString("bus-stop-display-name"); /** * I'm not very sure if you are coming from an Intent. * Some launchers work in strange ways. */ tryedFromIntent = busStopID != null; } } //---------------------------- END INTENT CHECK QUEUE -------------------------------------- if (busStopID == null) { // Show keyboard if can't start from intent showKeyboard(); // You haven't obtained anything... from an intent? if (tryedFromIntent) { // This shows a luser warning ArrivalFetchersRecursionHelper.reset(); Toast.makeText(getApplicationContext(), R.string.insert_bus_stop_number_error, Toast.LENGTH_SHORT) .show(); } } else { // If you are here an intent has worked successfully setBusStopSearchByIDEditText(busStopID); this.lastSuccessfullySearchedBusStop = new Stop(busStopID); // forcing it as user name even though it could be standard name, it doesn't really matter this.lastSuccessfullySearchedBusStop.setStopUserName(busStopDisplayName); new asyncWgetBusStopFromBusStopID(busStopID, ArrivalFetchersRecursionHelper, lastSuccessfullySearchedBusStop); } Log.d("MainActivity", "Created"); }
From source file:com.miz.mizuu.fragments.IdentifyMovieFragment.java
public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); mToolbar = (Toolbar) v.findViewById(R.id.toolbar); ((MizActivity) getActivity()).setSupportActionBar(mToolbar); mListView = (ListView) v.findViewById(R.id.listView1); mQuery = (EditText) v.findViewById(R.id.editText1); mSpinner = (Spinner) v.findViewById(R.id.spinner1); mProgress = (ProgressBar) v.findViewById(R.id.progressBar1); mListView.setOnItemClickListener(new OnItemClickListener() { @Override//from www. j ava 2 s .c om public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { updateMovie(arg2); } }); mListView.setEmptyView(v.findViewById(R.id.no_results)); v.findViewById(R.id.no_results).setVisibility(View.GONE); // Manually make it gone to begin with mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mLocale = mSpinnerAdapter.getItem(position).getLanguage(); searchForMovies(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mSpinnerAdapter = new LanguageAdapter(); mSpinner.setAdapter(mSpinnerAdapter); String language = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(LANGUAGE_PREFERENCE, "en"); mSpinner.setSelection(mSpinnerAdapter.getIndexForLocale(language)); mQuery.setText(mMovieStructure.getDecryptedFilename()); mQuery.setSelection(mQuery.length()); mQuery.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s.toString().length() > 0) searchForMovies(); else { mMovieSearch.cancel(true); mAdapter.clearItems(); mAdapter.notifyDataSetChanged(); } } }); mQuery.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN || actionId == EditorInfo.IME_ACTION_SEARCH) searchForMovies(); return true; } }); if (mMovieSearch == null) { if (MizLib.isOnline(getActivity())) { mMovieSearch = new MovieSearch(getActivity(), mQuery.getText().toString()); } else { Toast.makeText(getActivity(), getString(R.string.noInternet), Toast.LENGTH_SHORT).show(); } } }
From source file:com.miz.mizuu.fragments.IdentifyTvShowEpisodeFragment.java
public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); mToolbar = (Toolbar) v.findViewById(R.id.toolbar); ((MizActivity) getActivity()).setSupportActionBar(mToolbar); mListView = (ListView) v.findViewById(R.id.listView1); mQuery = (EditText) v.findViewById(R.id.editText1); mSpinner = (Spinner) v.findViewById(R.id.spinner1); mProgress = (ProgressBar) v.findViewById(R.id.progressBar1); mListView.setOnItemClickListener(new OnItemClickListener() { @Override/*w w w .j av a 2s .co m*/ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { updateShow(arg2); } }); mListView.setEmptyView(v.findViewById(R.id.no_results)); v.findViewById(R.id.no_results).setVisibility(View.GONE); // Manually make it gone to begin with mSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { mLocale = mSpinnerAdapter.getItem(position).getLanguage(); searchForShows(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mSpinnerAdapter = new LanguageAdapter(); mSpinner.setAdapter(mSpinnerAdapter); String language = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(LANGUAGE_PREFERENCE, "en"); mSpinner.setSelection(mSpinnerAdapter.getIndexForLocale(language)); mQuery.setText(mShowTitle); mQuery.setSelection(mQuery.length()); mQuery.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (s.toString().length() > 0) searchForShows(); else { mTvShowSearch.cancel(true); mAdapter.clearItems(); mAdapter.notifyDataSetChanged(); } } }); mQuery.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN || actionId == EditorInfo.IME_ACTION_SEARCH) searchForShows(); return true; } }); if (mTvShowSearch == null) { if (MizLib.isOnline(getActivity())) { mTvShowSearch = new TvShowSearch(getActivity(), mQuery.getText().toString()); } else { Toast.makeText(getActivity(), getString(R.string.noInternet), Toast.LENGTH_SHORT).show(); } } }
From source file:com.bitants.wally.fragments.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false); if (rootView != null) { super.onCreateView(rootView); quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background); quickReturnView = rootView.findViewById(R.id.quick_return_view); quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear); quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() { @Override// w w w .ja va 2s . c om public void onClick(View v) { if (quickReturnEditText != null) { query = ""; quickReturnEditText.setText(""); quickReturnEditText.performClick(); showKeyboard(quickReturnEditText); } } }); quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext); quickReturnEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { quickReturnEditText.setCursorVisible(true); restoreQuickReturnView(); } }); quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { return search(); } return false; } }); quickReturnEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { quickReturnEditTextClearButton.setVisibility(View.VISIBLE); } else { quickReturnEditTextClearButton.setVisibility(View.GONE); } } @Override public void afterTextChanged(Editable s) { } }); gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); float currentTranslationY = quickReturnView.getTranslationY(); float maxTranslationY = quickReturnHeight; float newTranslationY = currentTranslationY + -dy; if (newTranslationY > 0) { newTranslationY = 0; } else if (newTranslationY < -maxTranslationY) { newTranslationY = -maxTranslationY; } quickReturnView.setTranslationY(newTranslationY); float percent = (-maxTranslationY) / 100.0f; float currentPercent = 100 - (newTranslationY / percent); quickReturnBackground.setAlpha(currentPercent / 100); quickReturnBackground.setTranslationY(newTranslationY); } }); colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker); colorPickerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagCard = rootView.findViewById(R.id.search_color_card); colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview); colorTagTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear); colorTagClearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { colorTagCard.setVisibility(View.GONE); colorPickerButton.setVisibility(View.VISIBLE); currentColor = null; query = quickReturnEditText.getText().toString(); gridView.setAdapter(null); showLoader(); getImages(1, query); } }); setupAutoSizeGridView(); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) { query = savedInstanceState.getString(STATE_QUERY, ""); Message msgObj = uiHandler.obtainMessage(); msgObj.what = MSG_IMAGES_REQUEST_CREATE; msgObj.arg1 = 1; msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES); uiHandler.sendMessage(msgObj); currentColor = savedInstanceState.getString(STATE_COLOR); if (currentColor != null) { int backgroundColor = Color.parseColor("#" + currentColor); int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT); colorizeColorTag(backgroundColor, textColor, textColor, currentColor); colorTagCard.setVisibility(View.VISIBLE); colorPickerButton.setVisibility(View.GONE); } currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE); } ((MainActivity) getActivity()).addOnFileChangedListener(this); ((MainActivity) getActivity()).addOnFiltersChangedListener(this); } return rootView; }
From source file:com.musenkishi.wally.fragments.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_search, container, false); if (rootView != null) { super.onCreateView(rootView); quickReturnBackground = rootView.findViewById(R.id.quick_return_protective_background); quickReturnView = rootView.findViewById(R.id.quick_return_view); quickReturnEditTextClearButton = (ImageButton) rootView.findViewById(R.id.quick_return_edittext_clear); quickReturnEditTextClearButton.setOnClickListener(new View.OnClickListener() { @Override//from w ww . ja v a 2s.co m public void onClick(View v) { if (quickReturnEditText != null) { query = ""; quickReturnEditText.setText(""); quickReturnEditText.performClick(); showKeyboard(quickReturnEditText); } } }); quickReturnEditText = (EditText) rootView.findViewById(R.id.quick_return_edittext); quickReturnEditText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { quickReturnEditText.setCursorVisible(true); quickReturnView.animate().translationY(0.0f).setDuration(300) .setInterpolator(new EaseInOutBezierInterpolator()).start(); quickReturnBackground.animate().translationY(0.0f).alpha(1.0f).setDuration(300) .setInterpolator(new EaseInOutBezierInterpolator()).start(); } }); quickReturnEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { return search(); } return false; } }); quickReturnEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (!TextUtils.isEmpty(s)) { quickReturnEditTextClearButton.setVisibility(View.VISIBLE); } else { quickReturnEditTextClearButton.setVisibility(View.GONE); } } @Override public void afterTextChanged(Editable s) { } }); gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); float currentTranslationY = quickReturnView.getTranslationY(); float maxTranslationY = quickReturnHeight; float newTranslationY = currentTranslationY + -dy; if (newTranslationY > 0) { newTranslationY = 0; } else if (newTranslationY < -maxTranslationY) { newTranslationY = -maxTranslationY; } quickReturnView.setTranslationY(newTranslationY); float percent = (-maxTranslationY) / 100.0f; float currentPercent = 100 - (newTranslationY / percent); quickReturnBackground.setAlpha(currentPercent / 100); quickReturnBackground.setTranslationY(newTranslationY); } }); colorPickerButton = rootView.findViewById(R.id.quick_return_color_picker); colorPickerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagCard = rootView.findViewById(R.id.search_color_card); colorTagTextView = (TextView) rootView.findViewById(R.id.search_color_textview); colorTagTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { showColorPickerDialog(); } }); colorTagClearButton = (ImageButton) rootView.findViewById(R.id.search_color_button_clear); colorTagClearButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { colorTagCard.setVisibility(View.GONE); colorPickerButton.setVisibility(View.VISIBLE); currentColor = null; query = quickReturnEditText.getText().toString(); gridView.setAdapter(null); showLoader(); getImages(1, query); } }); setupAutoSizeGridView(); if (savedInstanceState != null && savedInstanceState.containsKey(STATE_IMAGES)) { query = savedInstanceState.getString(STATE_QUERY, ""); Message msgObj = uiHandler.obtainMessage(); msgObj.what = MSG_IMAGES_REQUEST_CREATE; msgObj.arg1 = 1; msgObj.obj = savedInstanceState.getParcelableArrayList(STATE_IMAGES); uiHandler.sendMessage(msgObj); currentColor = savedInstanceState.getString(STATE_COLOR); if (currentColor != null) { int backgroundColor = Color.parseColor("#" + currentColor); int textColor = savedInstanceState.getInt(STATE_COLOR_TEXT); colorizeColorTag(backgroundColor, textColor, textColor, currentColor); colorTagCard.setVisibility(View.VISIBLE); colorPickerButton.setVisibility(View.GONE); } currentPage = savedInstanceState.getInt(STATE_CURRENT_PAGE); ((MainActivity) getActivity()).addOnFileChangedListener(this); ((MainActivity) getActivity()).addOnFiltersChangedListener(this); } } return rootView; }
From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity2); mPlanetTitles = getResources().getStringArray(R.array.menu_array); drawerView = findViewById(R.id.drawer); mTitle = mDrawerTitle = getTitle();//ww w .j a v a2 s .c o m titleTextView = (TextView) findViewById(R.id.textViewTile); prefs = PreferenceManager.getDefaultSharedPreferences(this); mUserName = (TextView) findViewById(R.id.textViewUserName); mUserNickName = (TextView) findViewById(R.id.textViewNickName); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerBtn = (Button) findViewById(R.id.left); findViewById(R.id.menu0).setOnClickListener(onClickListener); findViewById(R.id.menu1).setOnClickListener(onClickListener); findViewById(R.id.menu2).setOnClickListener(onClickListener); findViewById(R.id.menu3).setOnClickListener(onClickListener); findViewById(R.id.menu4).setOnClickListener(onClickListener); autoCompleteAdapter = new AutoCompleteDbAdapter(MainActivity2Activity.this, null, false); inputCarNo = (AutoCompleteTextView) findViewById(R.id.title); inputCarNo.setAdapter(autoCompleteAdapter); inputCarNo.setThreshold(4); inputCarNo.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Cursor cursor = (Cursor) adapterView.getItemAtPosition(i); String number = cursor.getString(cursor.getColumnIndexOrThrow("PLATE_NUMBER")); Intent intent = new Intent(MainActivity2Activity.this, SendMsgActivity.class); intent.putExtra("destNo", number); inputCarNo.setText(""); startActivity(intent); } }); inputCarNo.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (inputCarNo.getText().toString().trim().length() == 4) { String tem = inputCarNo.getText().toString().substring(inputCarNo.getText().length() - 2, inputCarNo.getText().length()); String condition = "PLATE_NUMBER LIKE '%" + tem + "'"; Cursor query = getContentResolver().query(DataProvider.PLATE_URI, null, condition, null, null); if (query.getCount() == 0 && !isPause) { Toast.makeText(MainActivity2Activity.this, "? .", Toast.LENGTH_SHORT).show(); } } } }); inputCarNo.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { switch (actionId) { case EditorInfo.IME_ACTION_SEARCH: Intent intent = new Intent(MainActivity2Activity.this, CarSearchActivity.class); intent.putExtra("inputCarNo", inputCarNo.getText().toString()); hideKeyboard(); isPause = true; startActivity(intent); break; default: return false; } return false; } }); RequestAllCarNo carNumbers = new RequestAllCarNo(); carNumbers.Action(MainActivity2Activity.this); ImageButton carNo = (ImageButton) findViewById(R.id.search_carNo); carNo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // cameraIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1); // startActivityForResult(cameraIntent, PICK_CAMERA_REQUEST); // inputCarNo.setText(""); Intent cameraIntent = new Intent(MainActivity2Activity.this, OilCamera.class); startActivityForResult(cameraIntent, PICK_CAMERA_REQUEST); } }); ImageButton voiceRec = (ImageButton) findViewById(R.id.search_voice); voiceRec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { promptSpeechInput(); } }); if (checkPlayServices()) { // Log.d("hts", "checkPlayServices "); _gcm = GoogleCloudMessaging.getInstance(this); // Log.d("hts", "_gcm : " + _gcm); if (TextUtils.isEmpty(_regId)) { registerInBackground(); } } mDrawerBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mDrawerLayout.isDrawerOpen(drawerView)) { mDrawerLayout.closeDrawer(drawerView); hideKeyboard(); } else { hideKeyboard(); mUserName.setText(prefs.getString(CONST.ACCOUNT_LICENSE, "")); mUserNickName.setText(prefs.getString(CONST.ACCOUNT_NAME, "")); mDrawerLayout.openDrawer(drawerView); } } }); if (false == checkGPS()) chkGpsService(); Bundle bundle = getIntent().getExtras(); if (!SharedPreferenceManager.getValue(this, SharedPreferenceManager.positionAgree) .equalsIgnoreCase("true")) { showDialogAree(); } if (null != bundle) { String pushNoit = bundle.getString(Common.PUSH_NOIT, Common.PUSH_NOIT); if (pushNoit != null && !pushNoit.isEmpty()) { selectItem(3); setTitle(getResources().getStringArray(R.array.menu_array)[3]); } } else { selectItem(0); setTitle(getResources().getStringArray(R.array.menu_array)[0]); } }
From source file:com.rong.library.widget.mapsearchbar.MapSearchBar.java
@Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { String q = searchEdit.getText().toString(); searchEdit.setText(""); searchEdit.clearFocus();/*from w ww . java2 s . c om*/ if (mListener != null) { if (!TextUtils.isEmpty(q.trim())) mListener.onSearchConfirmedAsync(q); } return true; } return false; }
From source file:huajiteam.zhuhaibus.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w . java 2s . com Bundle bundle = getIntent().getExtras(); config = new GetConfig(this); if (config.getIsFirstRun()) { makeAlert(getString(R.string.open_source_license), new OpenSourceLicense().getLicense()); PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("first_run", false).apply(); } final String recMsg = getStringFromBundle(bundle, "msg"); final String link = getStringFromBundle(bundle, "link"); if (recMsg != null && !recMsg.equals("")) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle("BROADCAST MESSAGE"); builder.setMessage(recMsg); String cancelButtonString; if (link != null && !link.equals("")) { builder.setPositiveButton(getString(R.string.update_broswer), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); } }); cancelButtonString = getString(R.string.cancel); } else { cancelButtonString = getString(R.string.okay); } builder.setNegativeButton(cancelButtonString, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); } final EditText editText = (EditText) findViewById(R.id.busLineInputBox); if (editText != null) { editText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); editText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { Log.i("Press", "" + actionId + " " + EditorInfo.IME_ACTION_SEARCH); if (actionId == EditorInfo.IME_ACTION_SEARCH) { String busLineText = editText.getText().toString(); if (busLineText.equals("")) { Snackbar.make(editText, getString(R.string.main_error_bus_line_null), Snackbar.LENGTH_LONG).setAction("Action", null).show(); } else { progressDialog = ProgressDialog.show(MainActivity.this, getString(R.string.connect_server_message), getString(R.string.waiting)); if (busLineText.toLowerCase().equals("fatfatsb")) { busLineText = ""; } if (config.getAutoUpper()) { busLineText = busLineText.toUpperCase(); } new SearchBus(busLineText, config.getBusApiUrl()).start(); } return true; } return false; } }); } Button bt = (Button) findViewById(R.id.searchButton); if (bt != null) { bt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String busLineText = null; if (editText != null) { busLineText = editText.getText().toString(); if (busLineText.equals("")) { Snackbar.make(editText, getString(R.string.main_error_bus_line_null), Snackbar.LENGTH_LONG).setAction("Action", null).show(); } else { progressDialog = ProgressDialog.show(MainActivity.this, getString(R.string.connect_server_message), getString(R.string.waiting)); if (busLineText.toLowerCase().equals("fatfatsb")) { busLineText = ""; } if (config.getAutoUpper()) { busLineText = busLineText.toUpperCase(); } new SearchBus(busLineText, config.getBusApiUrl()).start(); } } } }); favoriteConfig = new FavoriteConfig(this); ListView listView = (ListView) findViewById(R.id.favOnMain); mAdapter = new MAdapter(this); if (listView != null) { listView.setAdapter(mAdapter); } } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); if (drawer != null) { drawer.setDrawerListener(toggle); } toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); if (navigationView != null) { navigationView.setNavigationItemSelectedListener(this); } }
From source file:com.morlunk.mumbleclient.servers.PublicServerListFragment.java
private void showFilterDialog() { View dialogView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.dialog_server_search, null); final EditText nameText = (EditText) dialogView.findViewById(R.id.server_search_name); final EditText countryText = (EditText) dialogView.findViewById(R.id.server_search_country); final AlertDialog dlg = new AlertDialog.Builder(getActivity()).setTitle(R.string.search).setView(dialogView) .setPositiveButton(R.string.search, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int which) { String queryName = nameText.getText().toString().toUpperCase(Locale.US); String queryCountry = countryText.getText().toString().toUpperCase(Locale.US); mServerAdapter.filter(queryName, queryCountry); dialog.dismiss();//from w w w . j a v a 2 s. co m } }).create(); nameText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); nameText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { String queryName = nameText.getText().toString().toUpperCase(Locale.US); String queryCountry = countryText.getText().toString().toUpperCase(Locale.US); mServerAdapter.filter(queryName, queryCountry); dlg.dismiss(); return true; } }); countryText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); countryText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { String queryName = nameText.getText().toString().toUpperCase(Locale.US); String queryCountry = countryText.getText().toString().toUpperCase(Locale.US); mServerAdapter.filter(queryName, queryCountry); dlg.dismiss(); return true; } }); // Show keyboard automatically nameText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { dlg.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } } }); dlg.show(); }