Stuck on MIT APP Inventor: - android

Once I have completed the form, I cannot see the the form's output in the ResultsLabel I created. Attached is a screenshot below, does it look OK?
All help appreciated!

Regarding your statement "I cannot see the form's output in the label", is it possible that it's hidden behind the keyboard? Press the 'Done' button to hide the keyboard when you're done typing.
Regarding your question "does it look OK":
Your first StoreValue event is saving the value as the tag, which probably isn't great practice but can work
However, your second StoreValue overwrites the first one, and the third StoreValue overwrites the second one because you're using the same tag for all three.
If you want to save the two thumbpositions for that particular name you should do this:
TinyDB.StoreValue
tag = {name.text}
value = {make a list
{cashrequired.thumbposition}
{period.thumbposition}

Related

How to add "show text" in Android(x) password preference dialog

There doesn't appear to be a specific password text dialog in the Androidx (or Android) library.
I want to add a button so that the user can switch between text view and password text view (asterisks instead of letters) for this preference even though, as someone might want to tell me, it's not a fabulous idea to store passwords as preferences. Eventually I'll have a more robust approach but in the meantime this is what I've got.
I'm using the code that Android Studio (generously) offers me for "Preference Activity". In all other respects it seems pretty good, and better than I can manage myself yet. It's just got this (annoying lack of) feature.
This question is a little too old to reference Androidx, and according to the (main) relevant answer to my context, I can't use AndroidX here. However, using the code from the Settings Activity I don't explicitly mention DialogPreference at all.
So, is there a way to slot in a "reveal" button in this situation, or should I either not use the "textPassword" input type, or completely rebuild this activity?
I was messing round with something similar the other day. I didn't use a reveal button, but just got it to never show the password:
input_password.setText(prefs.getYourPassword().toAsterix())
private fun String.toAsterix(): String {
return replace("[.]", "*")
}
With a PreferenceActivity, you would have to make a custom view. It would be an EditText and a Button. Clicking the button would set the text to either prefs.getYourPassword() or prefs.getYourPassword().toAsterix().

How to build a TinyDB with values from CheckBox and TextBox in App Inventor2?

I'm trying my best to learn App Inventor2.
Although I'm a little familiar with coding in Java with Eclipse and Android Studio and I'm aware of App Inventor limitations, I like most, the graphical interface and the visual objects, than developing an app all the way in code.
I'm having a screen in an app as the following image, that I need to achieve this functionality:
a. User checks a "CheckBox" related to an image of their liking.
b. User inputs some identification related (id1, id2) to this image.
c. Clicks the "Save" button to store this values (checkBox, id1,id2) to a TinyDB.
d. Clicks the "Reset" button to clear info stored in TinyDB (checkBox, id1,id2).
I know that TinyDB can only store text. I have tried to make a TinyDB with a tag as a list named "idList" and have it populated with the values from "checkBox", "id1","id2", without success. I believe that I'm knot checking weather the "checkBox" changed or something like that.
Can someone be kind enough to point me to the right direction following this logic, or point me to something better if I'm wrong?
Thank you all in advance for your answers.
in the button click event you need some logic to find out, which checkbox has been checked, something like this (pseudocode)
if checkbox1.checked then store the text 1,
elseif checkbox2.checked then store the text 2,
etc.
in TinyDB you can store a list with the result of that logic and the text from the textboxes like this
also you have to read the values from TinyDB again. Normally you do this in the Screen.Initialize event, example:
in case you do not like the advanced blocks, you can do the same with some regular blocks, too...
See also
How to work with Lists by Saj
How to work with Lists and Lists
of lists (pdf) by appinventor.org

Android : onSearchRequested() capture text

I am developing a sample for searching functionality.
I have used onSearchRequested() and on calling it, I get an edit box in which I can enter
the search parameter.
What I would like to do is, I want to capture the text entered in the edit box as I would like to send it to another activity.
Generally for an editText that is defined by us , we can access it using its 'id'.
But, since in the case of onSearchRequested(), the editText is creted automatically , so how can I access and capture the text typed in it.
Have a look at the documentation regarding creating a search interface. Part of the documentation is an example on how to set up a SearchableActivity that is called with the query entered by the user and that should do the searching and showing the results. I guess this is exactly what you want.

Android: Button to new screen and show sql data

I am working a project. I have lots of word text data and don't want to add layout and class for each one. I want to use sqlite, but don't know how. For example, there is a button, id is cat.
When clicking the cat button, a new screen opens and shows information of cat. One layout, one class, but lots of screens. The data must come from sql because there are too many animals.
Thanks in advance.
You have given the answer already yourself: SQL database may be your friend. Work yourself through this tutorial and see how far that brings you. You'll have to manipulate the UI from code, that is doable as well.
Another approach you might want to consider is putting everything in XML into strings.xml file(s). This depends a bit on the size and structure of your data. From code you can reach this using getString( R.id.blah ).
Call other screen passing values.
In the button click do:
startActivity(new Intent(this, SecondScreen.class).putExtra('Identify', 'Value'));
In the Second Screen do:
String value = getIntent().getStringExtra('Identify');
Now, take that value and make the query in SqLite and display the result.

Android: need to validate an edittext for non-blank input

If I want to enforce a maximum length of input in an EditText field, I can use the maxLength attribute. But if I want to enforce a minimum length (in my case, simply non-blank), I find no corresponding minLength attribute.
I've also looked at the various 'inputType' attributes (phone, password, etc) but I don't see anything like 'required' or 'non-blank'.
I can't believe this would require a custom input filter; it's more likely the answer is so obvious it just doesn't get written down in the form I'm asking the question.
You can simply check that yourField.text() is not equivalent to null or "" at the point of submission. If it is, prompt the user to input something.
Carefull with something though. If you have a submit button, for instance, and your user presses submit without changing the focus out of your TextEdit, your method won't be called.
Take an Activity with 2 EditTexts and 1 button named "Go":
1) User writes something in EditText1
2) User clicks on EditText2
3) Instead of writting something there just clicks go.
Your onFocusChanged() method won't be called because focus is not "lost".
If you have a validation in your Go button_click method, it will trigger, of course, but you won't achieve your goal "I was looking/hoping for was a way to give instant feedback"
You can try using TextWatcher.

Categories

Resources