• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Getting form results

Where can I see an example for getting the following and using them to create an object with a constructor?
*a boolean from a checkbox
*a String from an EditText field
 
I'm not an Android programmer, but I have some experience programming for Windows.
But since both IDE's are object oriented, my best guess is that you set the value of your boolean or other variable in the click or change event of your object.

Hope this helps.
 
Figured it out. I eventually realized I had to create Java objects corresponding to each checkbox and editText thing.

Maybe this code will help someone else:

public void onClickSubmitEventButton(View view){
//Intent intentToSubmitNew = new Intent(this, NewEventActivity.class); -- need to change "NewEventActivity.class"
//startActivity(intentToLogNew);
final CheckBox checkboxCause = (CheckBox) findViewById(R.id.checkBoxCause);
final CheckBox checkboxEffect = (CheckBox) findViewById(R.id.checkBoxEffect);
final CheckBox checkboxRhythm = (CheckBox) findViewById(R.id.checkBoxRhythm);
String eventName = "";
boolean cause = false;
boolean effect = false;
boolean rhythm = false;
if (checkboxCause.isChecked()){
cause = true;
}
if (checkboxEffect.isChecked()){
effect = true;
}
if (checkboxRhythm.isChecked()){
cause = true;
}
eventName = ((EditText) findViewById(R.id.editText1)).getText().toString();

//Event ___somename__ = new Event(eventName, cause, effect, rhythm);
//replace "somename" with a generated string that will also be loaded into an array containing
// all the event names that have been created so far
 
Back
Top Bottom