After some time my xml files declaration are changing. sometimes when I open it my textvalues are changing from my #string values to regular texts. In this case:
android:id="MAC Adress" Can someone explain why?
<EditText
android:layout_width="330dp"
android:layout_height="wrap_content"
android:hint="#string/mac" <!-- <-- THIS -->
android:id="#+id/editText_mac"
android:maxLength="17"
android:paddingLeft="15dp"
android:paddingRight="15dp" />
it is a nice feature of AndroidStudio. It shows the content pointed by the id. But you are still using the reference to the localized value. As matter of fact, if you click on the text, you will see again #string/ instead of the value pointed by it
try clicking on it, you'll see the previous string path. It just hides to make it clear and easy to access the string , instead of the path to string. It's the same with every one...
Related
I have some EditText views in a RelativeLayout. The first one receives focus correctly, but when the user clicks "Finished" on the keyboard, it usually doesn't send focus to the view the user expects. Assuming that the "Finished" button uses the FOCUS_FORWARD ID, I have tried to fix this behaviour by using the android:nextFocusForward attribute like so:
<EditText
android:id="#+id/editTextName"
...
android:nextFocusForward="#id/editTextNameColour" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editTextNameColour"
...
android:nextFocusForward="#id/editTextBackgroundColour" />
<EditText
android:id="#+id/editTextBackgroundColour"
... />
It doesn't compile because Eclipse gives me an error message like: "error: Error: No resource found that matches the given name (at 'nextFocusForward' with value '#id/editTextNameColour')".
I know the name is correct because I selected it from a dropdown list in Eclipse and all files have been saved.
Android Developers Reference says that EditText is the right type (a View).
If there's a better way than using android:nextFocusXxx attributes, including doing it in the Java code, that's fine too.
I'm not open to solving this by using a LinearLayout.
Also, am I right that the "Finished" button uses the FOCUS_FORWARD?
Thanks
Solution: I need to use #+id... rather than #id because I am referencing objects declared later in the code; and the keyboard appears to use FOCUS_DOWN rather than FOCUS_FORWARD.
It's because of #id vs #+id. Just use #+id. You're trying to use an ID before its been assigned a resource. You can also switch the order around that you're declaring stuff, if its in relativeLayout.
If that is the order, then you are referencing elements that hasn't been defined yet. You should do something like:
<EditText
android:id="#+id/editTextName"
...
android:nextFocusForward="#+id/editTextNameColour" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editTextNameColour"
...
android:nextFocusForward="#+id/editTextBackgroundColour" />
<EditText
android:id="#+id/editTextBackgroundColour"
... />
This is more a 'is there a more appropriate way' question as I have found a work around.
Some of my table headers are being picked up as spelling errors and underlined in red. Of course, that is not what I would like to see. I have found that using
android:inputType="textNoSuggestions"
does disable the spell check markings. I find it odd (bug?) that this is necessary as the docs state:
inputType: The type of data being placed in a text field, used to help
an input method decide how to let the user enter text.
and there is no input associated with just textView. So is this the only/more appropriate way of avoiding the spell check and also, is this a bug that it is spell checking non-input fields?
UPDATE: per request this is sample xml
<TextView
android:text="ID#"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:typeface="monospace"
android:textSize="14sp"
android:digits="4"
android:textAlignment="gravity"
android:layout_weight="5"
android:gravity="left"
android:singleLine="true"
android:phoneNumber="true"
android:inputType="textNoSuggestions|none">
</TextView>
First, I would try removing the android:digits, android:phoneNumber, and android:inputType attributes.
All of those are more intended for use with fields that allow input (such as EditTexts). It also doesn't look like you are using the android:digits attribute correctly, as the string you provide defines the only allowable characters.
In essence, this combination of attributes is telling Android that your TextView accepts input in the form of telephone numbers that contain only the number 4, that this TextView doesn't accept input of any type, and Android should not provide spellcheck suggestions.
If you are setting the content of the TextView yourself, there really is no reason to try to restrict the content of the TextView with flags such as android:phoneNumber since you are the one controlling that.
I know this is an old thread but removing the following from content XML worked for me:
android:autoText="true"
On later android studio versions try:
android:autoText="true"
inside of the (or any input) in the xml.
On newer versions try:
android:inputType="textNoSuggestions"
What is the meaning of this warning?
No label views point to this text field with an android:labelFor="#
id/# id/editText1" attribute
Note that the double id (#id/#id) is a problem with the error message text and does not reflect the XML content (which is the correct syntax).
The labelFor is an attribute for accessibility options. You assign this to a label so that if, on a form , user clicks a textedit field , android can know what to read (TalkBack) to user.
The id you assigned to it doesn't seem to be a valid one. why there are two #id in the id? Use ids like this: #id/editText1
I've had the same warning message. It disappeared, when I added a hint to my EditText
android:hint="Some explanation about the input..."
Although I am not familiar with the exact error you have posted. But it definitely sounds like you have done something wrong with the id in the textView. Use id like following in your textView.
android:id="#+id/editText1"
And if you want to set labelFor then use :
android:labelFor="#+id/editText1"
It means that you probably should define a label for this edit text and link them using a labelFor inside that labels definition.
example code:
<TextView
android:id="#+id/my_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:labelFor="#+id/my_editText" <!--the plus sign goes first in the code-->
android:text="I'm a label" />
<EditText
android:id="#id/my_editText" <!--no plus sign if not the first-->
android:layout_width="wrap_content"
android:inputType="text"
android:layout_height="wrap_content" />
and it's not only for text views.
Remove th first '#id/' , use like
android:id="#+id/editText1"
which is the correct format. Keep going.. Best wishes.. :)
I solved it by writing both attributes:
android:id="#+id/editText1"
android:labelFor="#+id/editText1"
Select the editText, go to Properties, then Label for and enter #id/EditText1
If the XML looks correct and you're in a Graphical Layout mode then it's probably using a later version of the Android rendering layout that doesn't support EditText.
In Eclipse and Android Studio there should be a green Android icon with what API version is rendering the layout. Make sure you're using a non W or Wearable API as Android W APIs don't support the EditText element. (EditText is most likely not supported because virtual keyboard space is limited on those devices).
The rendered preview should support EditText in any API 4.X version without a trailing W.
Can some one help me, I have heard alot of things and I dont know what to believe. I am making an app that is a counter. In my xml layout i have a TextView acting as a counter and the text is set by a string in strings.xml and i am controlling what the text view says from my java file. here is some code snip its. all I want to know is this ok?, it works fine but I want to know is it a bad or good way.
"counter" equals a variable.
"display" is referencing the ID of the textview"
what i am using to control the text view.
display.setText(String.valueOf(counter));
here is my text view in my xml layout
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/tvDisplay"
android:gravity="center"
android:text="#string/counter"
android:textSize="20dp" />
here is the string in strings.xml
<string name="counter">0</string>
It's fine, that's how you change text dynamically.
Yes, All things are right and good. Yo should have to give the String Value as like that.
If there is a Small Value of TextView then you can directly give as android:text="abcd"
And If you want to give any reference of that then your code is also correct and works as well.
For the Best use of coading your should have to try as like you have done rightnow. as Because it helps you a lot if there are number of TextView and you want to manage or change the Value of it quickly.
Enjoy. :)
Thanks.
In a a custom list view, I have a textview showing name and emailId. When the name provided is something like A-TestThisString(testA#test.com), the length of displayed area exceeds,
In that case the string is broken at the place of hyphen like
A-
is shown in the list. This is causing lots of problems. I have found one link which talks about solution bellow
topic: "Android: How do i make nonbreakable block in TextView?"
but, I am not able to understand how to use it. Please suggest.
Thanks for your help. I found the answer. use the inputType as email or singleLine=True, it starts working fine.
I used android:inputType="date", no line breaks and hyphen is displayed nicely
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="2-3 4-5"
android:inputType="date"
android:textSize="25sp" />