So i have multiple edittext's in one constraint layout and i cannot get my multiline edittext to do a linebreak from enter, i have tried settings imeOptions to normal, actionUnspecified, actionNone and actionDone and no luck, it does not do a line break. Could not find anyone with this issue, only opposite =)
What am i doing wrong? here is the code for my edittext
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="text|textImeMultiLine|textCapSentences"
android:ems="10"
android:singleLine="false"/>
have you tried android:maxLines, like android:maxLines="10"?
Related
Im having trouble undestanding what is happening here.
If I don't mess with "setFocusable" on EditText it works like I excpect (when you click on it the keyboard pops up and you can edit it as normal), if I set it to true it also works like before:
holder.editTextExercise.setFocusable(true);
But if I set it to false, and than back to true, I can no longer see a keyboard pop up, so I can't edit it
holder.editTextExercise.setFocusable(false);
holder.editTextExercise.setFocusable(true);
Here is the EditText
<EditText
android:id="#+id/recyclerExercise"
android:layout_width="0sp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textColor="#color/grey"
android:backgroundTint="#color/grey"
android:text="#string/app_name"
android:textSize="25sp"/>
Im putting different items with EditTexts in the recycler and sometimes I want to change them so they can/can't be editable.
What is going on here?
Instead of
holder.editTextExercise.setFocusable(false);
holder.editTextExercise.setFocusable(true);
Try
holder.editTextExercise.setEnabled(false);
holder.editTextExercise.setEnabled(true);
I created a EditText and set maxLenght to 200. But when I type more than 200 characters and try to erase the text, first it erases the characters that are not shown. How do I avoid this?
If you are ok with using multiple lines for your EditText add android:inputType="text|textMultiLine", then all 200 characters will fit into the EditText.
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="#+id/fieldDescription"
android:hint="Descrição(até 200 caracteres)"
android:maxLength="200"
android:layout_marginBottom="15dp" />
This isn't much of a question, more of an explanation, I like to know whats happening and not treat things like a black box. I'm making an android app, and I created a form where you can dynamically make a new field to add to the form, and the field has 2 edit text next to each other.
formLayout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<EditText
android:id="#+id/team_form_player_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="7dp"
android:layout_weight="1"
android:background="#color/white"
android:hint="#string/form_hint_team_player_name"
android:inputType="textCapWords"
android:padding="15dp"/>
<EditText
android:id="#+id/team_form_player_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#color/white"
android:hint="#string/form_hint_team_player_number"
android:inputType="number"
android:padding="15dp"/>
</LinearLayout>
And this is inside a button listener when clicked, it'll create the new field
View layout = getLayoutInflater().inflate(R.layout.layout_add_new_field_team, null);
EditText name = (EditText)layout.findViewById(R.id.team_form_player_name);
EditText number = (EditText)layout.findViewById(R.id.team_form_player_number);
playerName.add(name); //arraylist
playerNumber.add(number); //arraylist
containerLayout.addView(layout);
being that its a different layout i had to inflate the view. anyway, my question is this. how does this even work? by code, I'm adding an edit text, each time to its respectful array. im adding the same layout each time, im not even using "new" so its not instantiating anything new. and if I create 10 fields at once, then fill in the fields. and run this method
for(EditText edit : playerNumber) {
String test = edit.getText().toString();
System.out.println(test);
}
it gives me all the correct values in each field. How does that happen? Because on add field click, it instantly adds the edit text to the array with the fields EMPTY. and theres no code inputting the values into the array. I'm just boggled that this works and would like to know how it does. anyone have any idea?
.inflate(layoutResId) == "create new instance of this layout"
So basically every time you use inflate you are creating instances of all the Views in the layout, in your case a LinearLayout and two EditText Views inside it.
I would like to have a EditText in my Android app that you can not see, however you can select and type text into. In other words I would like it so that it can not be seen at all however other than that it behaves completely normally.
Another option is to have an image or button on the screen which the user presses to enter text into the EditText which is hidden behind another EditText.
Thanks for the help, however it is looking more likely that I will have to use the second option. To elaborate on it, for example I have a TextView that says 'Welcome'. I would like the user to be able to click on this text to bring up the keyboard and edit in the EditText field. The reason for having the EditText field hidden behind another is to cover up the cursor while making it seem the user is typing the text which appears on the screen.
If you would like to make the EditText fully invisible (even what the user types in) , but still be able to retrieve the entered data through myEditText.getText().toString(),
you could add:
android:textColor="#android:color/transparent"
android:background="#00000000"
android:cursorVisible="false"
if I'm getting you correctly. Here is how you can accomplish the first option of yours by setting the background to transparent and cursor visibility to false.
To check this you have to click at the center of screen.
e.g. code snippet:
<EditText
android:id="#+id/eT1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#00000000"
android:cursorVisible="false"
android:ems="10" >
</EditText>
Set transparent Background to EditText.
android:background="#00000000"
Sorry but I didn't understand your another question.
I have a RadioGroup inside of a RelativeLayout. I've got a few RadioButtons for different options, like "Bob", "Joe", and "Fred". However, I need to add an "Other..." option with an EditText right next to a RadioButton in case a user wants to enter "Steve". Is there a way to do this?
Just one idea that comes to mind is to use android:layout_marginLeft and android:layout_marginTop tags to position the EditText field where you need it to be. Be sure to use dip to support multiple densities across devices.
<EditText
android:layout_marginLeft="65dip"
android:layout_marginTop="100dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="" />
Then, if the user selects your Other radio button, just grab the value from EditText.