I'm writing an app the is does a lot of calculating and I'd like to accomplish some calc when I leave an EditText. Nothing fancy, things like entering 7/16 and having 0.4375 as the result or 1.0259 * 7 and having 7.1813 as the result. The function wouldn't be used all the time but would eliminate a couple of steps when needed.
Thanks Steve
I asked the wrong question, but the comment posted got me thinking, needed to look at substrings.
I've figured out what I need.
Related
I have some problem with java.util.ConcurrentModificationException. When I deleted one characater or more in my autocompletetext I got force close. Anybody knows what happen with that ? and what is the solution for that problem ?
Thank You.
It looks like you are adding and deleting something from your collection at same point of time. By doing this, you are structurally modifying the collections more than once at single point of time. Hence you are getting java.util.ConcurrentModificationException, which is the result of "Fail-Fast" iterators being used in your collections.
You can have a look at this link which explains fail-safe and fail-fast iterators.
what-is-fail-safe-fail-fast-iterators-in-java-how-they-are-implemented and checkout the answer written by Stephen C.
Hy, I'm writing an application and i have a big problem with the keylock while the program runs. In the app there's a page with full of numbers. After I made the keylock on and back to off all the numbers are doubled. for example: 100% after keylock: 200%, 16/16 after keylock 32/32. Could you please help me?
I don't have any idea what could be the problem.
You need to identify the lines of code causing the error. Nobody can answer this directly w/o any of your code. Not many SO users will even try to read long code blocks.
Save your current code as a backup and reduce it to the relevant lines that produce the error. You will find a solution yourself or you can then post the code.
From your comment I can guess that in method onResume you modify a field variable. If you know the life cycle of android Activity you know that onResume is called each time the activity is shown to the user. The field variable state is preserved and simply adding a value each time is not the same as assigning a value.
I'm designing a spaceship game in App Inventor. I have a label (lblScore) update when the ship is hit each time. When the ship is hit 3 times, I want the code inside that to execute yet it doesn't work. I've tried multiple variations of this, such as setting it to lblScore.Text instead. Any idea's on how I can address the issue?
Is the lblscore a label?
If it is all you need to do is have a collision block saying whenever the spaceship gets hit, set lblscore = lblscore + 1
This should fix your issue but I would like to see all of your blocks
Do you increment your lblScore in the Ship.CollidedWith event?
If yes, you should move your if statement there, but instead of using the lblScore component as currently, you should better use the lblScore.Text property instead.
Probably it would help us to help you, if you provide a screenshot of your Ship.CollidedWith event...
I have a strange situation I can't explain myself.
The following code works well:
solo.sleep(1000);
assertTrue(solo.searchText("Banking"));
but the following code fails:
assertTrue(solo.waitForText("Banking", 1, 1000));
Can someone can explain me this?
Kind regards,
Alban.
The problem is that '1000' in waitForText isn't setting a delay, it's setting how long to keep looking. If it doesn't find the text within that time, it returns false. See Robotium source
Try the second version like this and see if it doesn't work:
assertTrue(solo.waitForText("Banking", 1, 10000)); // Take up to 10 seconds
Also, the delay before the first one probably doesn't change anything. I think the first example would work just as well if it was only:
assertTrue(solo.searchText("Banking"));
Before robotium-1.7.1 there were some issues with searchText(). It was definetely not always finding the text even when it should. You might want to try again with simple code without timing.
myInput.setText(myInput.getText().replace(myInput.getSelectionStart(), myInput.getSelectionEnd(), myText));
myInput.setSelection(myInput.getSelectionStart() + myText.length(), myInput.getSelectionEnd() + myText.length())
I ask because I think this code is much longer than it needs to be - Is there something shorter like myInput.insertTextAtCursor(myText) or is this the way everyone does it?
I don't think there is... but nothing prevents you from creating a utility method for this, if you find yourself repeatedly writing the same two lines.