I want to get input from user . The inputs are text type such as name email phoneno :
Is EditText is the right way for reading input ?
Also i want to have the title of the input to be displayed like
Name
Email
And the data to be entered after these title.
So is it possible to have my cursor start from right end of the EditText and push characters to left as and when entered.
Also , now when i do gettext , even the title will be part of the read text .
IS there a way to get only the user input from EditText
<EditText android:id="#+id/name" android:layout_height="wrap_content"
android:text="Name" android:inputType="textPersonName"
android:layout_width="fill_parent" android:layout_below="#+id/textview1"
android:textSize="15sp" android:textStyle="bold">
</EditText>
Q: Is edittext is the right way for reading input?
A: Sure. Why not? There are other alternatives, but "EditText" is a good choice.
Q: And the data to be entered after these title. SO is it possible to
have my cursor start from right end of the edittext and push
characters to left as and when entered?
It's customary to pair a TextView (also called a "label" on other, non-Android platforms) next to your EditText. The label is read-only; the EditText field is changeable. Wrap both in a Layout to make sure the "prompt" is adjacent to the "edit":
EditText Label?
for the title, you can use:
-textView above the editText
-in the editText property in the xml, set the android:hint
Related
i have an password edittext with this property :
android:inputType="textPassword"
I want to mask typed chars in edittext with dots but in default way android shows typed chars , how to mask them and prevent to be shown at first (just like html password fields) ?
I think this could be done with a TextWatcher. It's a listener that you would set on your editText. In particular the method 'beforeTextChanged'. You would be able to store off what they have typed internally and replace the string with whatever character you wish.
https://developer.android.com/reference/android/text/TextWatcher.html
With an EditText it is possible to add an entry to support alphanumeric digits like the following:
android:digits="#string/alphanumeric_allowed_chars_free_textentry"
Where the string is defined as
<string name="alphanumeric_allowed_chars_free_textentry">
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-=[];,./~!##$%^</string>
However, as others have noted, when a user sets the digits attribute, it can cause the "enter" button to show a return arrow instead of a next or done button, as described in this related question
The typical solution to get done to show up is to set android:singleLine="true" and android:imeOptions="actionDone", but this will only work for an input box which is not a multi-line box. I have a multi-line edit text and would like to be able to add a done button and also fliter using the digits attribute.
Does anyone know how to allow an EditText to use digits while also being multiline, while also allowing the return button to show "done"? Android 4.4
What if you modify alphanumeric_allowed_chars_free_textentry to include carriage return (\r, \n)?
i was unable to reply / comment to your comment
So added new answer
in multiline edittext
after adding \r\n to my digits property
android:digits="1234567890#$%^&*()_+-=qwertyuiopasdfghjklzxcvbnm:;,.?/|~`{}[]QWERTYUIOPASDFGHJKLZXCVBNM+x÷x€£¥₩×\r\n ●■□⊙☆¤•°《》¿¡\"
i am able to goto nextline on enter as well using the digits property.
below is my axml code "
i was unable to reply / comment to your comment
in multiline edittext after adding \r\n to my digits property android:digits="1234567890#$%^&*()_+-=qwertyuiopasdfghjklzxcvbnm:;,.?/|~`{}[]QWERTYUIOPASDFGHJKLZXCVBNM+x÷x€£¥₩×\r\n ●■□⊙☆¤•°《》¿¡\"
i am able to goto nextline as well using the digits property .
"
<EditText
android:id="#+id/NewTask_TaskDescription"
style="#style/MultiLineTextboxStyle"
android:layout_marginBottom="10dp"
android:layout_height="151dp"
android:layout_width="match_parent"
android:inputType="textCapSentences|textMultiLine"
android:singleLine="false"
android:digits="1234567890#$%^&*()_+-=qwertyuiopasdfghjklzxcvbnm:;,.?/|~`{}[]QWERTYUIOPASDFGHJKLZXCVBNM+x÷x€£¥₩×\r\n ●■□⊙☆¤•°《》¿¡\\" />
"
how can i get the exact value of the specific word in a textview when:
1 - the user had taped the word (the word can be just one of many in some text chunk),
2 - the textview has in its xml layout, android:textIsSelectable="true" ,
so by default android lets the user to highlight a specific word
and opens a small menu(copy, paste, share). can i manipulate this menu or maybe add more options to it in order to extend it and do something i want with the highlighted word?
i need to get the exact word based on some interaction with the user(click , tap, select....)
i didn't find any straight forward answer. is it even possible?
(i have android htc one x)
Thanks.
A more suitable component to use for your scenario is EditText.
It is declared like this in your manifest file:
<EditText
android:text=" This is not an editable EditText"
android:id="#+id/EditText01"
android:layout_width="wrap_content"
android:textColor = "#android:color/white"
android:editable = "false"
android:cursorVisible="false"
android:layout_height="wrap_content"
android:background = "#android:drawable/dark_header">
</EditText>
Then, it is only two lines of code to get the selected text:
EditText et = (EditText)findViewById(R.id.title);
String selectedText = et.getText().substring(et.getSelectionStart(), et.getSelectionEnd());
Here, we assumed that the text was selected from left to right. If it was selected from right to left, then above would result in an exception so you can avoid that by checking if start position is higher than the end position.
I have an EditText in my Activity that users must enter date in it in my desired format like ____/__/__. Is there any way to show this format in EditText of Android like mask textboxes of some programming languages?
Thanks,
editText.setHint("____/__/__");
OR
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="____/__/__"/>
EDIT
I would recommend a DatePicker though rather than having users enter numbers and slashes. If DatePicker is not an option, I would then recommend 3 EditTexts that each have their own hint and which possibly automatically move between each other when they reach their automatic size.
[2012]/[01]/[01]
You could do separate Edittexts with textviews of "/" between them and then concatenate them...
In Android, while entering password the text is displayed. Is there any way to hide the text programmatically?
Set the inputType to password. Either in the xml (as an attribute of your EditText):
android:inputType="textPassword"
or in your program:
yourETView.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
In your XML that holds the input field use the following:
android:inputType="textPassword"
it's depend on the real device. means In device whatever the user use the devices have 1 one option was available in the setting for hide/show the text while typing text in password field so no need to worry about it, for accept text as password you can set the input type of edittext like this way
android:inputType="textPassword"
in xml layout file