Intents for EditText LongPress - android

i want my application to be seen when a user long presses on edit text to copy or paste.
or clicks on copy or paste.
i tried with different intents like
ACTION_PASTE ,
ACTION_EDIT
But none are working for me !!
Please help me out
Thanks in advance.

There is no way for you to automatically appear in the action mode or context menu that appears when the user selects text in an EditText for other applications.
For your own EditText widgets, you can use setCustomSelectionActionModeCallback() to add items to the standard action mode on API Level 11+.

Related

Default text in the serach bar with AutoCompleteTextView

I'm using the AutoCompleteTextView to allow users to search a from a list of countries. I want to have some default text preloaded in the search bar before the user clicks on it, such as "Search" or "Find Nearest Country". Is it possible to do this? If so how?
Right now, the app opens directly into the search box with the keyboard pulled up. Rather, I want the users to click on the bar before searching.
http://developer.android.com/reference/android/widget/AutoCompleteTextView.html
A TextView's hint seems to be exactly what you need. See android:hint for the XML attribute or setHint() for the corresponding Java method.
To prevent the keyboard from popping as soon as your activity is entered, you should set the android:windowSoftInputMode attribute in the activity declaration to stateHidden.

Android - UX design conventions concerning "Cancel" and "Done" buttons

I am new to Android and I am creating an app in which you have a form which you can save similar to how it is done in the contacts app.
My question is: how should I display "Cancel" and "Done" buttons? Should I even display a "Cancel" button in the first place, since the hardware back button (or the action bar's up-navigation) should suffice?
The screenshot below shows how it is done in the Contacts app, but I am wondering if this is "the way to go", because this way the buttons take a lot of screen space for no reason. On iPhone you have a small "Done" button on the top right (inside the navigation bar / action bar). I tend to do the same for this Android app, but I don't want to do anything that users don't expect.
So can someone please help me out here? :)
For this particular case, put the "Done" in a contextual action bar.
Back does not work as "Cancel" - it should also persist whatever edits made so far.
(Buttons like "Done" and "Cancel" are valid in an alert dialog but that is not the case here.)

How to Intercept the keyguard(software menu) clicks for eg "Settings" menu option click?

Is there a way to find out when did a user click "Setting" options on the screen menu?
The onClick listner's KeyDown events catches only the hardware buttons on the phone and not the clicks of the sofware keyboard that shows up when a textbox/editText gets a focus and the key guard shows up.
Is it even possible using public android SDK.
P.S. : I am only concerned with 2.2 and 2.3 so its fine if this is not possible on 3.0 and above.
Thnx
EDIT
Explanation of a scenario that will help understand the question better!
I have a full screen activity with a editText and a button. I want to intercept all the clicks that a user make and based on that make some decisions.
I am able to register a listner to intercept what phisical keys are being clicked(HOME, MENU, VOLUME UP/DOWN etc)...The problem is, when the user clicks on the editText i.e. the text box gets the focus, the sotware keypad shows up. Now I also want to intercept what keys(numbers, alphabets, special characters or even custom functions on some samsung android phone like 'Go To Settings' are clicked and perform action based on the clicks.
My question is, is it possible and if yes, then how?
NOTE: Please dont ask me why am I doing this because its bad user experience. I am very much aware of that. I am trying to do this in a particular context that needs this functionality. Thnx!
You need to use the KeyListener class and setKeyListener
http://developer.android.com/reference/android/widget/TextView.html
This only allows you to modify/filter input into the TextView.

Interface from text selection tool (where copy/paste is)

I would like to add a button in android when a user selects texts then clicks the context button (e.g. it shows copy, cut, paste, select all). Can someone please direct me to the libraries or some resource where I can potentially learn about this?
Trying to search for it, I'm kind of lost because I really don't even know where to start. Does android provide a direct library to access this? If so, in what namespace might I find these functions?
Thank you!
I would like to add a button in android when a user selects texts then clicks the context button (e.g. it shows copy, cut, paste, select all).
There is no "context button" in Android.
On an EditText widget, "Cut, Copy, Paste, Select All" is displayed in one of three ways:
Via a context menu. You can attempt to add menu items to this menu via onCreateContextMenu().
Via an action mode on Android 3.0+. You can call setCustomSelectionActionModeCallback() on the EditText to add new items to the action mode. Note that the action mode is not always displayed, due to either a bug or an inexplicable UI decision.
Via something else, as some Android 2.x device manufacturers elected to do their own thing for cut/copy/paste with an EditText that is not a context menu.
For copy and paste you can simply use-
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
clipboard.getText() / clipboard.setText(yourText);
Just implement above lines on click of your button. And this is for Context Menus.

Displaying many Action keys on soft-key on Android

I am relatively new to Android development. My requirement is such that I have a multiple line input box(such as comment box); as the user clicks the box a soft-key keyboard appears on screen which has either an "Enter" button or "Next" Button as an Action key.
I want the keyboard to have both, "Enter" as well as "Next" Button and also the comma(,) button.
I have searched throughout the web. They only have options to specify the "android:imeOptions" tag. But this option does not give the desired output as I need.
Kindly help.
PS: I do not want to create a custom keyboard. Just want to modify the existing soft-key keyboard to be displayed.
Also, I am working on Android v2.2
Thanks for your help.
I want the keyboard to have both, "Enter" as well as "Next" Button and also the comma(,) button.
There is, at most, one action key for an input method editor (a.k.a., soft keyboard). You cannot have two. Depending on the input method editor, you may have zero, as the input method editor is not obligated to show an action key.

Categories

Resources