Remove attribute across all edittexts - android

Is it possible to remove a feature (autocorrect, in this case) across the entire app from every single edit text by running an extension? Our app has a lot of edit texts across several activities and I would like to avoid running over each file to hit every one just to avoid adding a line of code, if possible. I have a style set up for that each one is connected to and tried adding
<item name="android:inputType">textNoSuggestions</item>
But that didn't do anything. Some of these fields do have input type set to be just number, and others I set for things like textCapWords or `textPersonsName' and things like that. I believe I made sure to give each one some kind of input, so is it because of that that the style line wasn't working?
I'm aware that I can just make a custom edit text and apply that to each layout file, but that would defeat the purpose of not running through each file.
tl;dr - Is there a way to remove autocorrect across every single activity without editing each layout file?

Related

\u221c unicode doesn't show on button

my problem is that I can't put '\u221c' unicode on button in Android app. '\u221a' is OK and works, but 221b and 221c doesn't. Also, when I want that button to put text '\u221c' in EditText it puts \u221a. I dont know why it works that way and how to fix this. Please help
This appears to be simply a font problem. U+221A SQUARE ROOT “√” is a much more common character in fonts than U+221B CUBE ROOT “∛” and U+221C FOURTH ROOT “∜”. You may need to find a font that contains them and bundle it into the application, or use other notations.
You can, in particular, use fractional powers instead of roots. That’s even the preferred way, according to the standard ISO 80000-2. So instead of ∜a, you would use “a” followed by “1/4” in superscript style, if that’s possible in the application.

what happen if do not put text files in string.xml in android?

i did not put some text in string.xml and there is a yellow alert symbol in side of Textview field. i want to know does it have problem and what happen, if do not put texts in string.xml in android?
Well, setting your text directly on your layout file can be a source of future problems and its not recommended.
Consider this scenario: You use the same string "Foo" in many layout files and then you decided to change to "Bar". If you have hardcoded that, you will need to make changes in all layout files and there might be a chance to leave some inconsistent text. But if you place it in the strings.xml file, you will have only to change in one place.
Also, if you want to add translations to your app, the Android system can handle it automatically for you if you use the strings.xml.
You might want to take a look here and here.
Nothing will happen.
string.xml used to:
localization
res/values-fr/strings.xml
res/values-ja/strings.xml
ease of editing and to save memory when reusing.
I Recommend you to put text files in string.xml
Whilst it will not cause a problem in the short term, it is not good practice and will cause you issues in the future if you decide to support multiple languages.

Can I edit a style dynamically?

I'm currently developing an app which should be totally customizable by endusers. Imagine the application has many activities with some TextViews, Buttons, etc.
So the client can create a XML file like this one:
<style >
<h1>25dp</h1>
<h2>30dp<h2>
<actionbar>#cecece</actionbar>
</style>
As you can imagine, for example, there are several TextViews which are always "titles" so they should always take this h1 value.
I know I can parse this XML file and for each textview, apply this style manually, but this is not a good way of achieving this because if I had 3000 textViews, I should manually edit them all.
What I want is to "edit" the actual Style programmatically.
Any tip?
You can't access a resource file in the created APK as they are compiled into it. So your idea to "customizable" styles works only in the following scenario:
your app is a library project
your client uses that library project and create a style which extends/overwrites your own style and compile that into a new APK
You are not clearly telling us if the "enduser" is a user of your app/apk or a customer that can do the above mentioned modifications.
An alternative might be to create your own extensions of TextViews, Buttons etc which can load your style set. You need to create your own style language for that and you need to make sure that the custom views understand and apply them.
A lot of work, if you ask me... I would, in general, suggest to make different themes so that the customer can pick the best suited for them...

which one is better? -Creating buttons at Run time or design time in android

i need to create around 26 buttons for simple task like display alphabets. i can do this by using layout design.
if i create this button at run time will it give more performance(Considering memory, speed,apk size!)?
Important Requirements:
this layout will be used by 4 different activities.
I need to display 26 buttons at a time to user.
These button may contain background
image.
edit: This layout is like pop up window for other four activities. user can press any alphabets in this layout. As soon as alphabets get selected layout will be closed
Since everything is static residing in your assets, it is fine to have everything in xml files.
Still, one can argue that the 'notion' of parsing the xml layout files of your project introduces an overhead to the process of creating the views.
I would go with a well-designed layout defined in xml.
Yikes. While XML is the best practice answer, 26 of anything screams for some dynamic run-time creation, or at least a combination of the two. You're not going to see much difference in processing time or apk size either way - it will come down to code maintenance down the line.
For instance, consider what will happen when you want to change or add a new attribute, say padding, for each of your letter buttons. Do you want to have to manually go change all those XML elements, or think about a clever regex to properly find/replace?
I'd go with a combination of styles, <include> statement, and run time modification for a comprehensive, maintainable solution. First create a single button styled how you think you want all your buttons to look. Extract your "LetterButton" style out to style.xml and use the android:style="#style/LetterButton" attribute on your button instead. This will allow you to change your style in a single file and have it affect all your letter buttons.
Next, extract the button itself into an <include> file. You can do this by right clicking on the GUI version of the button and choosing "Extract include...". Then arrange your <include>-buttons however you need to, perhaps in a <TableLayout>. Make sure you give each one a unique id, like #+id/letter_button_0 up through _25. The text attribute for all these buttons can be anything, you'll set those dynamically later.
Finally, in your onCreate, define an array of ints of the form {R.id.letter_button_0, ...}, and an array of Strings of the form {"A", ...}, and iterate over those, doing a button = findbyId(int), button.setText(String) to put a letter on each of your buttons.
It may seem like more work this way, but you're doing all the heavy lifting creating a smart UI, so that down the line you can change code in a single place (style or include) and all your buttons will be updated.
Strongly recommend XML layouts for best practice and more understandable code. Also, If you are worried about performance for large view, use relative layouts, these are faster to render than other types of layouts such as LinearLayouts.
Showing XML is best practice:
http://developer.android.com/guide/topics/ui/declaring-layout.html
Also to increase performance keep the Buttons as Activity member variables, then they only need to be loaded once from resources.
Hope that helps,
Marc
You should create it at xml file and make visible and invisible as you need.
You could create a layout with having static assets in it & have dynamic text content & for dynamic backgrounds.You can have use the button properties of gone & visible in it.

Updating Android EditText's hint on focus change using XML only

I read with interest user sunit's answer to this question about updating an EditText's hint but have been unable to find any documentation on using the method that I presume he appears to describe there: using the <selector> element in an XML layout to dynamically adjust attributes of an EditText at runtime when the element is focused/unfocused.
In my case I am actually more interested in adjusting the android:inputType element (because the hint disappears for me when the inputType is specified) but adjusting the hint would work just as well.
To be clear I know how to make this change in Java code--I'm trying to find out if there is a way to specify the behavior in XML. Thanks!
I'm afraid it isn't yet possible. <selector> is only valid to be applied in making state lists out of Drawable and Color resources, it does not yet work for Strings.
With regards to your mention of adjusting android:inputType to make the hint disappear, this is actually a known Android bug that will eventually be fixed in later versions so I wouldn't recommend building your code around this functionality as it will break when they fix it:
http://code.google.com/p/android/issues/detail?id=13895
Since you mentioned that you already know how to do this in the Java code, I won't point out how to call setHint() from within a OnFocusChangeListener ;)
Cheers.

Categories

Resources