I have a very simple layout made of TextViews and disabled EditTexts put by turns. Most of the EditTexts contain plain text but I have two special fields and I have problem with them:
Phone number: as an autoLink type I set "phone". The problem is that a phone number is invisible until I click inside the edit:
<EditText
android:id="#+id/service_order_contact_phone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:focusable="false"
android:enabled="false"
android:inputType="phone"
android:gravity="right"
android:autoLink="phone" >
</EditText>
I would like to enable user to click address to open google map. I set an autoLink attribute to "map" but it seems not to work. Do you know how to do it?
<EditText
android:id="#+id/service_order_address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:enabled="false"
android:focusable="false"
android:singleLine="false"
android:lines="2"
android:inputType="textPostalAddress|textMultiLine"
android:autoLink="map"
android:gravity="right" >
</EditText>
I don't think EditText and autoLink are designed to work together... Think about this scenario when the user is editing a value:
The user enters a phone number, say: 5557891234
The user made a mistake and clicks in the middle of the EditText to be able to change a digit in the middle of the phone number...
Instead of being allowed to edit the number, the link action takes them to the dialer with the incorrect phone number.
Related
I'm trying to implement something like a text editor.
I want to have a possibility to edit a long string without word-wrapping.
The edited string should be scrolled horizontally.
New line should be entered only when I press Enter.
So, my editor should be able to edit as long string as user desires (with horizontal scrolling) and be simultaneously multi-lined.
<EditText
android:id="#+id/editor"
android:background="#android:color/transparent"
android:scrollHorizontally="true"
android:lineSpacingExtra = "3sp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:typeface="monospace"
android:textSize="16sp"
android:inputType="textMultiLine"
android:scrollbars="vertical|horizontal"
android:gravity="left|top"
android:text="Code editor"
tools:ignore="HardcodedText"/>
In this case long strings are word-wrapped.
And
android:inputType="text"
gives me a possibility to edit long strings in one line... but how to enter a new line?
Pressing [Enter] doesn't enter a new string, just the next focusable element is selected.
I tried all combinations that could imagine, but nothing worked properly.
Either the text is multi-lined with word-wrapping or it's presented in one wide line.
I wondering if it's possible at all, to get such desired behaviour.
Now I'm thinking about subclassing EditText and manually handling Enter pressing.
But I don't like this approach.
How to get horizontally scrollable EditText with 'multiline' feature?
Any ideas?
You can combine the MUTILINE input type and the ability to scroll horizontally:
editText.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_FLAG_MULTI_LINE);
editText.setHorizontallyScrolling(true);
or in xml :
<EditText
android:inputType="text|textMultiLine"
android:scrollHorizontally="true"
.../>
I have the following AutoCompleteTextView :
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:textSize="20sp" >
</AutoCompleteTextView>
The input to this AutoCompleteTextView is done via a "Dialer" Layout I've created , thus this AutoCompleteTextView is android:enabled="false" and in order to add the user input on my AutoCompleteTextView I use the following code :
String mText =_searchAutoCompleteTextView.getText().toString()+_dialer_digits[position]; //the digit the user clicked upon
_searchAutoCompleteTextView.setText(mText);
_searchAutoCompleteTextView.performCompletion();
if(_searchAutoCompleteTextView.getText().toString().length()>2 && _searchAutoCompleteTextView.getAdapter().getCount()> 0)
{
_searchAutoCompleteTextView.showDropDown();
}
Every thing is working fine except a weird issue :
Since the input is not done by the device's keyboard and only by my dialer with setText() , if the user clicks alot of digits whihc are longer than the AutoCompleteTextView's size last digit is broken and while continuing to input more digits the AutoCompleteTextView does not scroll left. The weird thing about it is that I've tried to enable it and put some long input from the device's keyboard it works perfectly , long text is not broken and scrolling is happening. Since I cannot use the device's keyboard it must be done via my layout and setText()
Many thanks ahead
EDIT:
here is a screen shot :
You can use append instead of setText to move the cursor to the end.
I'm not sure if this will work but have you tried to put your AutoCompleteTextView in a HorizontalScrollView?
<HorizontalScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content">
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:textSize="20sp" >
</AutoCompleteTextView>
</HorizontalScrollView>
Can you provide a screen shot so I can better understand the issue you are having?
You need to set Gravity of AutocompleteTextVIew to right:
<AutoCompleteTextView
android:id="#+id/contact_list_auto_complete_text_view"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=" Enter number"
android:singleLine="true"
android:gravity="right"
android:textSize="20sp" >
</AutoCompleteTextView>
I'm trying to make a text box about 3 lines high but also the textbox will also expand depending on the amount of information entered. I've used wrap_content which displays as one line and I've used android:layout_height="150dp", however the text box does not expand. Any guidance would be much appreciated.
<EditText
android:id="#+id/editEmailCompose"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/editEmailSubject"
android:layout_toRightOf="#+id/textSubject"
android:ems="10"
android:gravity="top|left"
android:layout_marginRight="20dp"
android:hint="#string/emailCompose" />
Ok so I found the code required. It may help others.
*android:layout_height="wrap_content"
android:isScrollContainer="true"
android:minHeight="120dp"
android:inputType="textMultiLine"*
I have a problem in input type attribute, I need a person name to be written in the edit text but when I run the application, the keyboard doesn't changed dynamically and it allows the user to enter any characters in the name field. Here is the code:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Name:"/>
<EditText
android:id="#+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
/>
It appears you can only use the input type attribute to limit to numbers. The link below might help you with you question.
https://stackoverflow.com/a/4401227/1157215
hi i want to create a control for my activty which is just like an android default dialpad number showing control. i created edittext control for it.
<EditText android:id="#+id/editid"
android:hint="Enter your number"
android:layout_width="fill_parent"
android:scaleType="center"
android:singleLine="true"
android:cursorVisible = "false"
android:layout_height="wrap_content"
>
</EditText>
But its not looking great as i am trying to show the inpput number from centre and keep on decreasing its text size if there are more numbers entered upto a certain size.Also i am unable to set its background drawable to make it look like dialpad's input box.
i also tried with button control.
<Button android:layout_height="45dp"
android:textSize = "25dp"
android:singleLine = "true"
android:id="#+id/input_number"
android:textColor = "#color/white"
android:layout_width="320dp"
android:background="#drawable/num_button">
</Button>
its showing exactly as i want but the problem is now i am not been able to set its text from qwerty keypad as edit text was taking it automatically.
Please someone suggest me which control to choose and get the desired behaviour.
Thanks
Set the gravity of Editext as center and it will work
android:gravity="center"