Robotuim - selecting text fields by index solo.enterText - android

We are trying to write a test for an Native Android App and this has been driving me nuts.
solo.enterText(6, "100");
solo.enterText(7, "200");
solo.enterText(8, "300");
solo.enterText(9, "400");
all work fine, but once the index goes over 10 it fails to find any of the fields.
solo.enterText(10, "500");
solo.enterText(11, "600");
It also seems a little crazy to be counting the text fields and from within UIAutomator Viewer it does not seem to provide the true index number.
Is there a way to select the text field by resource id or the field name instead of the index number?
thanks for your help

Try this:
EditText editText
=(EditText)getActivity().findViewById(R.id.editText);
mSolo.enterText(editText,"500");
using R file and id resourse should be easier to test editText

My guess is that if you look at the screen you will only be able to see 10 edit text boxes and the edit texts with index 10+ are off the screen and inside a list view so they do not actually exist to robotium, you will need to scroll before you can input text but then the indexs will be off so you will have to compensate. The alternative is to find the edit texts by a different means like id or a tag or to find them as a child of the listview row that they are in.
If you can confirm it is because its in a list view i can find some code to help you.

Related

Android - Custom EditText for Odometer Entry

I'm building am app that will allow Odometer entry. I would like to use the image shown below as the background on an EditText. Doing that is no problem, however I can not seem to get the digits entered into the text view to line up in the spaces of the image. I've tried adjusted the text size, font face, etc.
Here is the image I would like to use...
Does anyone have any suggestions on how I can accomplish this? So that when the user entered digits into the EditText, each digit goes into the correct "slot"?
thank you!!!
You can use android:letterSpacing? (only applies api 21 and over)
Set up 6 separate EditTexts on top of that image each with dimensions of the square they need to go into. Then set up event handlers so that it appears to be one fluid motion across EditTexts when the user enters data. Not very elegant but it'll work.

Create a textfield which only supports copy-option

Is there a way to make a textfield (EditText, TextView) on Android which displays copyable text (no edit options)? Something like Swing's JTextField().setEditable(false) on Windows?
Edit: It seems that my question was a little bit unclear, so I'm going to give it some real-world context. I am working on a checksum calculator which lets you pick a file and prints the results of the calculation into 4 different textfields. I want the user to be able to copy those hashes from the textfield, but to disable all edit options.
I believe what you are asking is very straightforward and simple, if I am reading your question wrong, please correct me!
Are the four text fields that hold the results required to be EditText 's?
otherwise - >
Question:
How to make TextView only copyable, not editable
Answer:
Well using a TextView solves the not editable part
and if you take a look
at my android studio. I have a simple TextView with an attribute of
textIsSelectable="true"
allowing users to copy and paste!
Hope this helped!
-Stephen

How to display word dictionary with custom keypad in android

I have successfully created a custom key pad in my application but i am unable to find out how to display a dictionary of words like android default keypad which appear at the top whenever we type.
1st you need to take an AutoComplete TextView
Afterwards , you need to follow this example:
Creating a Search Interface
In this example the ListView's Data-Source is being changed when the text is entered in Search Bar.You need to change the Data-Source of AutoComplete TextView as the user enters different texts.
I hope this will solve your problem.

Android NOT autoComplete or spinner

I have related input text fields in my android application.
The user first enters a parent value (using autocomplete text)
for the related child text entry i have tried a spinner and autocomplete text.
the spinner shows existing values, which is a good start, however i need the user to be able to enter new values as well. Once the user adds a new value this will be incorporated in the drop down list on subsequent views of the screen.
the user may not know all available values so autocomplete doesnt satisfy my requirements as you have to know what is already in the list for it to assist you.
i feel spinner is the best starting point for my child text entry field.
How do i enable text entry into a spinner?
whats the "Best" solution for this problem?

What is the difference between text field types

I am new to android. I was stuck on a problem but I finally solved it.
I was using a TextField instead of CompleteTextViewField so whats the difference between these two and when should I use each one of them?
Thanks
Neither of those classes you mention (TextField, CompleteTextViewField) exist. Do you mean EditText and AutoCompleteTextView? I think the documentation explains it pretty well:
[AutoCompleteTextView is] An editable text view that shows completion suggestions automatically while the user is typing. The list of suggestions is displayed in a drop down menu from which the user can choose an item to replace the content of the edit box with.
That is, use it rather than a normal EditText if you have a set of common autocompletions for what gets entered in the box. The docs also link to a full sample that shows how to populate that list of suggestions with an Adapter.

Categories

Resources