I would like to begin by saying I have little to no android experience, this is my first ever project within android and my teacher isn't quite teaching, so I apologize for any excessive ignorance.
To explain before I go any further: The goal of my app is essentially the ability to bank how many hours you have spent doing certain activities, record the times, and then display them in graphs. What I'm currently working on is creating text fields that will allow the user to type in how many hours they spent in each activity and then add them up to total hours spent, and I want this to be done without the usage of a button, which led me to look up textWatcher tutorials.
package com.example.gideon.timemanagement;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.widget.EditText;
import android.text.TextWatcher;
import android.widget.TextView;
public abstract class Customize extends AppCompatActivity implements TextWatcher {
EditText a;
EditText b;
TextView ht;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customize);
EditText a = (EditText) findViewById(R.id.exerciseHours);
EditText b = (EditText) findViewById(R.id.sleepHours);
TextView ht = (TextView) findViewById(R.id.healthTotal);
}
private TextWatcher Ht = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (!a.getText().toString().equals("") && !b.getText().toString().equals("")) {
ht.setText(String.valueOf(Integer.valueOf(a.getText().toString()) + Integer.valueOf(b.getText().toString())));
}
}
};
This is the code that I currently have for this particular activity. Before I implemented any of this I could get into the screen and enter data on the layout, however, once I began attempting to input the code I've had nothing but issues. This code finally allowed to me build the gradle, but now whenever I attempt to enter the activity it crashes the entire app.
Any help is appreciated, and off topic tips would be helpful as well!
Edit: Made changes(Updated Code in the original post to match, so that should be changed as well) and still have a crash, so I found the logcat and will be posting it immediately after this paragraph:
02-10 18:53:40.167 23713-23713/com.example.gideon.timemanagement I/zygote:
Not late-enabling -Xcheck:jni (already on)
02-10 18:53:40.174 23713-23713/com.example.gideon.timemanagement W/zygote:
Unexpected CPU variant for X86 using defaults: x86
02-10 18:53:40.393 23713-23713/com.example.gideon.timemanagement
I/InstantRun: starting instant run server: is main process
02-10 18:53:40.532 23713-23731/com.example.gideon.timemanagement
D/OpenGLRenderer: HWUI GL Pipeline
02-10 18:53:40.662 23713-23731/com.example.gideon.timemanagement I/zygote:
android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColor
ay retrieved: 0
02-10 18:53:40.662 23713-23731/com.example.gideon.timemanagement
I/OpenGLRenderer: Initialized EGL, version 1.4
02-10 18:53:40.662 23713-23731/com.example.gideon.timemanagement
D/OpenGLRenderer: Swap behavior 1
02-10 18:53:40.662 23713-23731/com.example.gideon.timemanagement
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED,
retrying without...
02-10 18:53:40.662 23713-23731/com.example.gideon.timemanagement
D/OpenGLRenderer: Swap behavior 0
02-10 18:53:40.682 23713-23731/com.example.gideon.timemanagement
D/EGL_emulation: eglCreateContext: 0xb1eabb60: maj 3 min 0 rcv 3
02-10 18:53:40.726 23713-23731/com.example.gideon.timemanagement
D/EGL_emulation: eglMakeCurrent: 0xb1eabb60: ver 3 0 (tinfo 0xb1eef120)
02-10 18:53:40.728 23713-23731/com.example.gideon.timemanagement
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
02-10 18:53:40.728 23713-23731/com.example.gideon.timemanagement
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
02-10 18:53:40.728 23713-23731/com.example.gideon.timemanagement
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
02-10 18:53:40.728 23713-23731/com.example.gideon.timemanagement
E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824
02-10 18:53:40.759 23713-23731/com.example.gideon.timemanagement
D/EGL_emulation: eglMakeCurrent: 0xb1eabb60: ver 3 0 (tinfo 0xb1eef120)