I want to insert text from field into a String array every time the add button is pressed, and when done so, the field should empty itself for a new string.
Here is my code:
Editor note: no code provided as example, only a screenshot of the code
Is the add function ever called? Otherwise you are sitting with a button without an onClickListener.
Try assigning The onClickListener in oncreate instead.
Related
I wrote a very simple FMX Adroid App, the function is:
Show Form 2 then write something to record(include title and detail text),
close Form 2 to Main Form, then make a checkbox in Main Form with the title we just recorded in Form 2.
if user check the checkbox, then press "del" buttn then delete the record file and checkbox.
the problem is:
when closed Form 2 and in MainForm::OnActivate we can add a new checkbox for the record.
if we checked checkbox then clicked delete, free the pointer of checked checkbox, the checkbox still in main form until I reopen the APP.
I tried:
Invalidate();
Application->ProcessMessages();
BeginUpdate();
EndUpdate();
Still can't work
does anyone know what's going on ? why FMX TForm member has no "Repaint()" or "Update()" "Refresh()" ? just like VCL has.
If you want your TCheckBox* (or any other control) disappear from a Form, you need to set its Parent property to nullptr before deleting it. If you created your control in runtime using new please remember to call delete.
//init
TCheckBox* checkBox = new TCheckBox(Form2);
//delete
checkBox->Parent = nullptr;
delete checkBox;
Answering the second part of your question, you can call Invalidate() function to repaint your whole Form (but first see first part of this answer). But I think it will run properly without calling this function.
Your controls have Repaint() member and it may be better to call them instead, ie. if your checkbox was placed in TPanel*, repainting only this panel is better idea than repainting whole form.
How can i take user input from popup dialogue and pass it into a BackGround Async Task?
I have a "createGarden" button. When i click it i want to retrieve a string from user, and pass it to my Background AsyncTask.
In my onClick, i have tried calling String myGardenName = getGardenName(), which returns input from dialogue. Then passing this into my Background task.
new HomeBackgroundTask().execute("create_garden", UserID_String,myGardenName );
I also tried using a value container, and passing this instead of "myGardenName":
String myGN = gnVC.getVal();
HomeBackgroundTask mhomebackgroundtask1 = new HomeBackgroundTask();
mhomebackgroundtask1.execute("create_garden", UserID_String, myGN);
instantiated my 'gardenValueContainer' value container as final in my "getGardenName()" method (enclosing class?) as well as instantiating it in my onCreate()
- I then try SETTING that value from within my onClick (inner class?)
--Also tried calling my HomeBackgroundTask directly from the onClick
Problem
Seems that my create garden always tries to insert a BLANK as the garden name. resulting in "garden "" already exists". When debugging, the user input get's passed through as a paramater, there was an issue with moving from "onPreExectute" to "doInBackground" but now when i'm debugging i get stuck in looper where i can't step over/into/out and my app just says freezes on connecting. (debug halts on a comment line, which might be bad?)
My php scripts work just fine with the same logic for registering a user.
No errors in my console!
http://pastebin.com/2AzWmcM5
Any help greatly appreciated!
"debug halts on a comment line, which might be bad"
Have you tried removing all breakpoints, or putting breakpoints on method implementations rather than on the, say, first line of the method?
I have a screen with an EditText and a ListView. As you type into the EditText, an AsyncTask is launched (any existing AsyncTask is cancelled and tossed) to query locally for some data to display in the ListView. If the EditText is empty of text, all data is queried for and displayed. Essentially, the EditText is a filter of the data on the screen. This is easy to do. In the addTextChangedListener, simply cancel your previous AsyncTask, launch a new one, and pass to it s.toString().
When the user hits the backspace to erase some text in the EditText, I want the default behavior (where all data populates the list). This works with my current implementation of addTextChangedListener.
However, I also have an X button on the right side of my EditText. This is intended to clear out the EditText (EditText.setText("");). This is a special case. In this case, I do not want the query to happen. The problem is, addTextChangedListener does not seem intelligent enough to know this. It gets triggered because the text has changed and all data is queried for.
How do I prevent this?
Use a boolean ignoreNextTextChangeKThxBye data member, setting/clearing that boolean as appropriate and using an if() statement to avoid doing the query.
I am using the the two editext and add the seperate textWatcher classes object
when some one give the focus then second one textListener is remove.
Then
My Question is how to check the textListener is add or remove
thnax in advance
AFAIK, There is no method to get the current assigne TextWatcher instance of the EditText object.
Rather you just can do like,
mEdiText.addTextChangedListener(null);
before you assign any TextWatcher and then assign the Watcher object mEdiText.addTextChangedListener(new MyTextWatcher()); to the EditText in any event or any condition.
Assigning null will remove the previous TextWatcher.
And to know is it really worked or not, just run your app and test it once.
on my app a have a form which contains 2 fields and a save button.
What do i need at the end of my onClick to return the cursor back to the first field.
i have this to clear them both
txtData.setText("");
txtData2.setText("");
but the cursor always stays on the bottom field
regards
Have you tried progamatically calling requestFocus on the view you want to have focus after the user clicks on your save button? For instance, you could in your onClick method do something like:
public void onClick(View){
//do other stuff like saving and clearing the fields
//then request the focus be switched back to the first text field.
txtData.requestFocus();
}