List of usage examples for android.view KeyEvent KEYCODE_ENTER
int KEYCODE_ENTER
To view the source code for android.view KeyEvent KEYCODE_ENTER.
Click Source Link
From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java
private void setupSearchMenu(MenuItem searchMenu) { search = searchMenu;/*from w w w . j ava 2 s. c o m*/ MenuItemCompat.setOnActionExpandListener(searchMenu, new MenuItemCompat.OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { final EditText field = (EditText) MenuItemCompat.getActionView(item) .findViewById(R.id.search_field); field.requestFocus(); InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.toggleSoftInput(0, 0); return true; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { EditText field = (EditText) MenuItemCompat.getActionView(item).findViewById(R.id.search_field); InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.hideSoftInputFromWindow(field.getWindowToken(), 0); return true; } }); MenuItemCompat.getActionView(searchMenu).findViewById(R.id.search_field) .setOnKeyListener(new View.OnKeyListener() { @SuppressWarnings("unchecked") @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { EditText field = ((EditText) MenuItemCompat.getActionView(search) .findViewById(R.id.search_field)); MenuItemCompat.collapseActionView(search); Projection projection = mapView.getProjection(); GeoPoint topLeft = projection.fromPixels(0, 0); GeoPoint bottomRight = projection.fromPixels(mapView.getWidth(), mapView.getHeight()); GeoCodingHandler.createDefaultHandler(geoCodingListener, field.getText().toString(), new RectF((float) topLeft.getLongitude(), (float) topLeft.getLatitude(), (float) bottomRight.getLongitude(), (float) bottomRight.getLatitude())) .execute(); } return false; } }); }
From source file:com.bydavy.card.receipts.activities.ReceiptListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { final MenuInflater inflater = getSupportMenuInflater(); inflater.inflate(R.menu.activity_receipt_list, menu); final MenuItem searchItem = menu.findItem(R.id.menu_search); mSearch = (EditText) searchItem.getActionView(); mSearch.setOnEditorActionListener(new OnEditorActionListener() { @Override/*from w w w.j av a 2s . c o m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((EditorInfo.IME_ACTION_SEARCH == actionId) || ((event != null) && (KeyEvent.KEYCODE_ENTER == event.getKeyCode()))) { search(v.getText().toString()); return true; } return false; } }); return super.onCreateOptionsMenu(menu); }
From source file:org.egov.android.view.activity.SearchActivity.java
/** * Event triggered when pressing enter/done key,call _getSearchList() function *///from w w w.jav a 2 s . co m @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) { _getSearchList(); } return false; }
From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java
/** * Display a new browser with the specified URL. * /*from ww w . j a v a2s.co m*/ * @param url * The url to load. * @param jsonObject */ public String showWebPage(final String url, JSONObject options) { // Determine if we should hide the location bar. if (options != null) { showLocationBar = options.optBoolean("showLocationBar", true); } // Create dialog in new thread Runnable runnable = new Runnable() { /** * Convert our DIP units to Pixels * * @return int */ private int dpToPixels(int dipValue) { int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue, cordova.getActivity().getResources().getDisplayMetrics()); return value; } public void run() { // Let's create the main dialog dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { try { JSONObject obj = new JSONObject(); obj.put("type", CLOSE_EVENT); sendUpdate(obj, false); } catch (JSONException e) { Log.d(LOG_TAG, "Should never happen"); } } }); // Main container layout LinearLayout main = new LinearLayout(cordova.getActivity()); main.setOrientation(LinearLayout.VERTICAL); // Toolbar layout RelativeLayout toolbar = new RelativeLayout(cordova.getActivity()); toolbar.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44))); toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2)); toolbar.setHorizontalGravity(Gravity.LEFT); toolbar.setVerticalGravity(Gravity.TOP); // Action Button Container layout RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity()); actionButtonContainer.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); actionButtonContainer.setId(1); // Back button ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); back.setId(2); try { back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); } }); // Forward button ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); forward.setId(3); try { forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); } }); // Edit Text Box edittext = new EditText(cordova.getActivity()); RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); edittext.setId(4); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); edittext.setImeOptions(EditorInfo.IME_ACTION_GO); edittext.setInputType(InputType.TYPE_NULL); // Will not except input... // Makes the text // NON-EDITABLE edittext.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { navigate(edittext.getText().toString()); return true; } return false; } }); // Close button ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); close.setId(5); try { close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png")); } catch (IOException e) { Log.e(LOG_TAG, e.getMessage(), e); } close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); } }); // WebView webview = new WebView(cordova.getActivity()); webview.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); webview.setWebChromeClient(new WebChromeClient()); WebViewClient client = new ChildBrowserClient(edittext); webview.setWebViewClient(client); WebSettings settings = webview.getSettings(); settings.setJavaScriptEnabled(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setBuiltInZoomControls(true); settings.setPluginsEnabled(true); settings.setDomStorageEnabled(true); webview.loadUrl(url); webview.setId(6); webview.getSettings().setLoadWithOverviewMode(true); webview.getSettings().setUseWideViewPort(true); webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setPluginsEnabled(true); webview.requestFocus(); webview.requestFocusFromTouch(); // Add the back and forward buttons to our action button container // layout actionButtonContainer.addView(back); actionButtonContainer.addView(forward); // Add the views to our toolbar toolbar.addView(actionButtonContainer); toolbar.addView(edittext); toolbar.addView(close); // Don't add the toolbar if its been disabled if (getShowLocationBar()) { // Add our toolbar to our main view/layout main.addView(toolbar); } // Add our webview to our main view/layout main.addView(webview); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.FILL_PARENT; dialog.setContentView(main); dialog.show(); dialog.getWindow().setAttributes(lp); } private Bitmap loadDrawable(String filename) throws java.io.IOException { InputStream input = cordova.getActivity().getAssets().open(filename); return BitmapFactory.decodeStream(input); } }; this.cordova.getActivity().runOnUiThread(runnable); return ""; }
From source file:com.irccloud.android.activity.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings({ "deprecation", "unchecked" }) @Override/*w w w .j a v a 2 s. co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); suggestionsTimer = new Timer("suggestions-timer"); countdownTimer = new Timer("messsage-countdown-timer"); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(screenReceiver, filter); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); if (cloud != null) { setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC)); cloud.recycle(); } } setContentView(R.layout.activity_message); try { setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); } catch (Throwable t) { } suggestionsAdapter = new SuggestionsAdapter(); progressBar = (ProgressBar) findViewById(R.id.progress); errorMsg = (TextView) findViewById(R.id.errorMsg); buffersListView = findViewById(R.id.BuffersList); messageContainer = (LinearLayout) findViewById(R.id.messageContainer); drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); redColor = getResources().getColor(R.color.highlight_red); blueColor = getResources().getColor(R.color.dark_blue); messageTxt = (ActionEditText) findViewById(R.id.messageTxt); messageTxt.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (event.getAction() == KeyEvent.ACTION_DOWN) nextSuggestion(); return true; } return false; } }); messageTxt.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (drawerLayout != null && v == messageTxt && hasFocus) { drawerLayout.closeDrawers(); update_suggestions(false); } else if (!hasFocus) { runOnUiThread(new Runnable() { @Override public void run() { suggestionsContainer.setVisibility(View.INVISIBLE); } }); } } }); messageTxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (drawerLayout != null) { drawerLayout.closeDrawers(); } } }); messageTxt.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } return true; } }); textWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { Object[] spans = s.getSpans(0, s.length(), Object.class); for (Object o : spans) { if (((s.getSpanFlags(o) & Spanned.SPAN_COMPOSING) != Spanned.SPAN_COMPOSING) && (o.getClass() == StyleSpan.class || o.getClass() == ForegroundColorSpan.class || o.getClass() == BackgroundColorSpan.class || o.getClass() == UnderlineSpan.class || o.getClass() == URLSpan.class)) { s.removeSpan(o); } } if (s.length() > 0 && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) { sendBtn.setEnabled(true); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(1); } else { sendBtn.setEnabled(false); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(0.5f); } String text = s.toString(); if (text.endsWith("\t")) { //Workaround for Swype text = text.substring(0, text.length() - 1); messageTxt.setText(text); nextSuggestion(); } else if (suggestionsContainer != null && suggestionsContainer.getVisibility() == View.VISIBLE) { runOnUiThread(new Runnable() { @Override public void run() { update_suggestions(false); } }); } else { if (suggestionsTimer != null) { if (suggestionsTimerTask != null) suggestionsTimerTask.cancel(); suggestionsTimerTask = new TimerTask() { @Override public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); update_suggestions(false); } }; suggestionsTimer.schedule(suggestionsTimerTask, 250); } } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }; messageTxt.addTextChangedListener(textWatcher); sendBtn = findViewById(R.id.sendBtn); sendBtn.setFocusable(false); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) new SendTask().execute((Void) null); } }); photoBtn = findViewById(R.id.photoBtn); if (photoBtn != null) { photoBtn.setFocusable(false); photoBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { insertPhoto(); } }); } userListView = findViewById(R.id.usersListFragment); View v = getLayoutInflater().inflate(R.layout.actionbar_messageview, null); v.findViewById(R.id.actionTitleArea).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { show_topic_popup(); } }); if (drawerLayout != null) { if (findViewById(R.id.usersListFragment2) == null) { upDrawable = new DrawerArrowDrawable(this); greyColor = upDrawable.getColor(); ((Toolbar) findViewById(R.id.toolbar)).setNavigationIcon(upDrawable); ((Toolbar) findViewById(R.id.toolbar)).setNavigationContentDescription("Show navigation drawer"); drawerLayout.setDrawerListener(mDrawerListener); if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } } messageTxt.setDrawerLayout(drawerLayout); title = (TextView) v.findViewById(R.id.title); subtitle = (TextView) v.findViewById(R.id.subtitle); key = (ImageView) v.findViewById(R.id.key); getSupportActionBar().setCustomView(v); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid")); buffer = BuffersDataSource.getInstance().getBuffer(savedInstanceState.getInt("bid")); backStack = (ArrayList<Integer>) savedInstanceState.getSerializable("backStack"); } if (savedInstanceState != null && savedInstanceState.containsKey("imagecaptureuri")) imageCaptureURI = Uri.parse(savedInstanceState.getString("imagecaptureuri")); else imageCaptureURI = null; ConfigInstance config = (ConfigInstance) getLastCustomNonConfigurationInstance(); if (config != null) { imgurTask = config.imgurUploadTask; fileUploadTask = config.fileUploadTask; } drawerLayout.setScrimColor(0); drawerLayout.closeDrawers(); getSupportActionBar().setElevation(0); }
From source file:com.www.avtovokzal.org.MainActivity.java
private void myAutoCompleteListener() { myAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override//from w w w . j a v a 2 s. c o m public void onItemClick(AdapterView<?> parent, View agr1, int pos, long id) { RelativeLayout rl = (RelativeLayout) agr1; TextView tv = (TextView) rl.getChildAt(0); nameStation = tv.getText().toString(); myAutoComplete.setText(nameStation); // ? InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(myAutoComplete.getWindowToken(), 0); code = tv.getTag().toString(); // ? ? loadScheduleResult(code, day, cancel, sell, all); myAutoComplete.clearFocus(); if (Integer.parseInt(code) == 102 && showDialogKoltsovo) { FragmentManager manager = getSupportFragmentManager(); KoltsovoDialogFragment dialogFragment = new KoltsovoDialogFragment(); dialogFragment.show(manager, "dialog"); } } }); myAutoComplete.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { int count = myAdapter.getCount(); if (count > 0) { AutoCompleteObject object = myAdapter.getItem(0); myAutoComplete.setText(object.toString()); code = object.getObjectCode(); // ? InputMethodManager inputMethodManager = (InputMethodManager) getSystemService( Activity.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(myAutoComplete.getWindowToken(), 0); // ? ? loadScheduleResult(code, day, cancel, sell, all); myAutoComplete.clearFocus(); if (Integer.parseInt(code) == 102 && showDialogKoltsovo) { FragmentManager manager = getSupportFragmentManager(); KoltsovoDialogFragment dialogFragment = new KoltsovoDialogFragment(); dialogFragment.show(manager, "dialog"); } } } return false; } }); }
From source file:com.tencent.wstt.gt.activity.GTLogFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View logLayout = inflater.inflate(R.layout.gt_logactivity, container, false); displayWidth = DeviceUtils.getDisplayWidth(getActivity()); rl_log_filter = (RelativeLayout) logLayout.findViewById(R.id.rl_log_filter); cb_logcatSwitch = (GTCheckBox) logLayout.findViewById(R.id.cb_logcat_switch); cb_logcatSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override//from w ww . j av a 2s . c o m public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // TODO logcat? logcatTask = new LogcatRunnable(); new Thread(logcatTask).start(); } else { logcatTask.killReader(); } } }); btn_delete = (ImageButton) logLayout.findViewById(R.id.gtlog_delete); btn_save = (ImageButton) logLayout.findViewById(R.id.gtlog_save); btn_open = (ImageButton) logLayout.findViewById(R.id.gtlog_open); btn_level_toast = (ImageButton) logLayout.findViewById(R.id.log_level_toast); btn_tag_toast = (ImageButton) logLayout.findViewById(R.id.log_tag_toast); /* * ??ImageView ??filterListViewfilterListView */ img_empty = (ImageView) logLayout.findViewById(R.id.view_empty); img_empty.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { img_empty.setVisibility(View.GONE); filterListView.setVisibility(View.GONE); cancelFilterMsgInput(v); return false; } }); /* * ? */ RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.gt_dailog_save, null, false); ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean); btn_cleanSavePath.setOnClickListener(this); et_savePath = (EditText) rl_save.findViewById(R.id.save_editor); String lastSaveLog = GTLogInternal.getLastSaveLog(); if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.LOG_POSFIX)) { lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf(".")); } et_savePath.setText(lastSaveLog); dlg_save = new Builder(getActivity()).setTitle(getString(R.string.save_file)).setView(rl_save) .setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // ?? String path = et_savePath.getText().toString(); try { File f = null; if (FileUtil.isPathStringValid(path)) { String validPath = FileUtil.convertValidFilePath(path, LogUtils.LOG_POSFIX); if (FileUtil.isPath(validPath)) { f = new File(validPath); f.mkdirs(); } else { f = new File(Env.ROOT_LOG_FOLDER, validPath); } GTLogInternal.setLastSaveLog(validPath); } if (f.exists()) { f.delete(); } LogUtils.writeLog(logAdapter.getUIEntryList(), f, false); } catch (Exception e) { e.printStackTrace(); } dialog.dismiss(); } }).create(); btn_save.setOnClickListener(this); // btn_delete.setOnClickListener(this); // btn_open.setOnClickListener(this); // rl_loglist = (RelativeLayout) logLayout.findViewById(R.id.rl_loglist); listView = (ListView) logLayout.findViewById(R.id.loglist); initCurLogAdapter(); logAdapter.setFilter(); listView.setAdapter(logAdapter); // button??? listView.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { rl_log_filter.setVisibility(View.GONE); } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (visibleItemCount + firstVisibleItem == totalItemCount) { logAdapter.setAutoRefresh(true); } else { logAdapter.setAutoRefresh(false); } } }); // button? rl_loglist.setOnClickListener(this); listView.setOnTouchListener(logListTouchListener); // ? filterListView = (ListView) logLayout.findViewById(R.id.spinner_list); tagAdapter = new ArrayAdapter<String>(getActivity(), R.layout.gt_simple_dropdown_item); filterListView.setAdapter(tagAdapter); filterListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View v, int position, long arg3) { img_empty.setVisibility(View.GONE); filterListView.setVisibility(View.GONE); if (parent.getAdapter() == tagAdapter) { if (position == 0) GTLogInternal.setCurFilterTag(""); else GTLogInternal.setCurFilterTag((String) parent.getAdapter().getItem(position)); btn_tag.setText(tagAdapter.getItem(position)); } else if (parent.getAdapter() instanceof MsgAdaptor) { String sCurSelectedMsg = (String) parent.getAdapter().getItem(position); LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList(); LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory(); GTLogInternal.setCurFilterMsg(sCurSelectedMsg); msgWatched = false; et_Msg.removeTextChangedListener(msg_watcher); String s = curShowDownMsgList.remove(position); curShowDownMsgList.addFirst(s); msgHistory.remove(s); msgHistory.addFirst(s); et_Msg.setText(sCurSelectedMsg); btn_msg_clear.setVisibility(View.VISIBLE); cancelFilterMsgInput(parent); } else { GTLogInternal.setCurFilterLevel(position); btn_level.setText(levelAdapter.getItem(position)); } onLogChanged(); } }); // Activity??? GTLogInternal.addLogListener(this); // ? //btn_search = (ImageButton) findViewById(R.id.log_search); btn_search = (ImageButton) logLayout.findViewById(R.id.gtlog_search); btn_search.setOnClickListener(this); // btn_level = (Button) logLayout.findViewById(R.id.log_level); levelAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.log_level, R.layout.gt_simple_dropdown_item); btn_level.setText(levelAdapter.getItem(GTLogInternal.getCurFilterLevel())); btn_level.setOnClickListener(this); // TAG btn_tag = (Button) logLayout.findViewById(R.id.log_tag); if (GTLogInternal.getCurFilterTag().length() == 0) { btn_tag.setText("TAG"); } else { btn_tag.setText(GTLogInternal.getCurFilterTag()); } btn_tag.setOnClickListener(this); // et_Msg = (EditText) logLayout.findViewById(R.id.log_msg); et_Msg.setText(GTLogInternal.getCurFilterMsg()); et_Msg.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus && !logAdapter.isEmpty())// edit? { msgEtOnFocusOrClick(); } } }); et_Msg.setOnClickListener(this); et_Msg.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: // ?showdown? msgWatched = false; et_Msg.removeTextChangedListener(msg_watcher); String word = et_Msg.getText().toString(); if (!word.equals("")) { LinkedList<String> curShowDownMsgList = GTLogInternal.getCurFilterShowDownMsgList(); LinkedList<String> msgHistory = GTLogInternal.getCurFilterMsgHistory(); msgHistory.remove(word); msgHistory.addFirst(word); curShowDownMsgList.remove(word); curShowDownMsgList.addFirst(word); } filterListView.setVisibility(View.GONE); img_empty.setVisibility(View.GONE); cancelFilterMsgInput(v); return true; } return false; } }); // ? btn_msg_clear = (ImageButton) logLayout.findViewById(R.id.log_msg_clear); btn_msg_clear.setOnClickListener(this); if (et_Msg.getText().toString().length() > 0) { btn_msg_clear.setVisibility(View.VISIBLE); } else { btn_msg_clear.setVisibility(View.GONE); } // ? btn_msg_input_cancel = (Button) logLayout.findViewById(R.id.log_msg_cancel); btn_msg_input_cancel.setOnClickListener(this); handler = new Handler(); return logLayout; }
From source file:com.mobicage.rogerthat.plugins.friends.RecommendServiceActivity.java
private void configureMailView() { T.UI();//from w w w . j ava 2 s .co m final AutoCompleteTextView emailText = (AutoCompleteTextView) findViewById(R.id.recommend_email_text_field); emailText.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, new ArrayList<String>())); emailText.setThreshold(1); if (mService.isPermitted(Manifest.permission.READ_CONTACTS)) { mService.postAtFrontOfBIZZHandler(new SafeRunnable() { @SuppressWarnings("unchecked") @Override protected void safeRun() throws Exception { L.d("RecommendServiceActivity getEmailAddresses"); List<String> emailList = ContactListHelper.getEmailAddresses(RecommendServiceActivity.this); ArrayAdapter<String> a = (ArrayAdapter<String>) emailText.getAdapter(); for (int i = 0; i < emailList.size(); i++) { a.add(emailList.get(i)); } a.notifyDataSetChanged(); L.d("RecommendServiceActivity gotEmailAddresses"); } }); } final SafeViewOnClickListener onClickListener = new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { String email = emailText.getText().toString().trim(); if (RegexPatterns.EMAIL.matcher(email).matches()) { mFriendsPlugin.shareService(mServiceEmail, email); emailText.setText(null); UIUtils.hideKeyboard(RecommendServiceActivity.this, emailText); AlertDialog.Builder builder = new AlertDialog.Builder(RecommendServiceActivity.this); builder.setMessage(R.string.service_recommendation_sent); builder.setPositiveButton(R.string.rogerthat, null); builder.create().show(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(RecommendServiceActivity.this); builder.setMessage(R.string.registration_email_not_valid); builder.setPositiveButton(R.string.rogerthat, null); builder.create().show(); } } }; ((Button) findViewById(R.id.recommend_email_button)).setOnClickListener(onClickListener); emailText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) { onClickListener.onClick(view); return true; } return false; } }); }
From source file:org.mklab.mikity.android.SettingsFragment.java
/** * {@inheritDoc}/*from www . j a v a2s .c om*/ */ public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) { final InputMethodManager inputMethodManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0); saveEnvironment(); return true; } return false; }
From source file:org.retroshare.android.ConversationFragment.java
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { boolean enterPressed = (event.getAction() == KeyEvent.ACTION_DOWN) & (event.getKeyCode() == KeyEvent.KEYCODE_ENTER); if (enterPressed) sendChatMsg(null);/*from w ww . ja v a 2 s . c o m*/ return enterPressed; }