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

Apps Textfield

Hey,

Kan iemand mij helpen met deze oefening?(zie bijlage)

Ik snap niet hoe je een textfield invoegd.

Alvast bedankt!

Groeten Wouter
 

Attachments

  • Android studio 07-09-2019.jpg
    Android studio 07-09-2019.jpg
    500.9 KB · Views: 175
Welcome to the site Wouter :)

This is an English forum, if you don't know English you can use Google Translate:
https://translate.google.com/


Translated:
Can someone help me with this exercise (see attachment)

I don't understand how to insert a textfield.

Thanks in advance!
 
You might find you'll get more help if you post your code as text rather than a photograph.
 
I don't understand how to insert a textfield.
To post code on this forum:

[CODE]
Your
Code
Here
[/CODE]


Here is the code from your attached document:
Code:
package com.example.oefenjava2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
    String rechtKinderbijslag;
    int leeftijd = 22;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        if (leeftijd < 18) {
            rechtKinderbijslag = "wel recht op kinderbijslag";
        } else {
            rechtKinderbijslag = "geen recht op kinderbijslag";
        }
        TextView myTextView = (TextView)findViewById(R.id.textview);
        myTextView.setText(rechtKinderbijslag);
    }
}
 
  1. package com.example.oefenjava2;
  2. import androidx.appcompat.app.AppCompatActivity;
  3. import android.os.Bundle;
  4. import android.widget.EditText;
  5. import android.widget.TextView;
  6. public class MainActivity extends AppCompatActivity {
  7. String rechtKinderbijslag;
  8. int leeftijd = 22;
  9. @override
  10. protected void onCreate(Bundle savedInstanceState) {
  11. super.onCreate(savedInstanceState);
  12. setContentView(R.layout.activity_main);
  13. if (leeftijd < 18) {
  14. rechtKinderbijslag = "wel recht op kinderbijslag";
  15. } else {
  16. rechtKinderbijslag = "geen recht op kinderbijslag";
  17. }
  18. TextView myTextView = (TextView)findViewById(R.id.textview);
  19. myTextView.setText(rechtKinderbijslag);
  20. }
  21. }


It will of course only become really interesting if the app user can enter his / her age himself. The app then shows whether the person is of age. Add this option. You can use an EditText for this. (sorry if it is translated incorrectly)
 
Hey,

What am I doing wrong with this code, he keeps saying app stops,

thank you in advance!

Greetings Wouter.

package com.example.kak;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
String childBenefit;
int age;



@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

EditText editAge = (EditText) findViewById(R.id.editText);
age = Integer.parseInt(editAge.getText().toString());



if( age < 18) {
childBenefit = "entitled to child benefit";
} else {
childBenefit = "no entitlement to child benefit";

}
TextView myTextView = (TextView)findViewById(R.id.textview);
myTextView.setText(childBenefit);
}
}
 
you mean this?

2019-09-20 20:04:47.508 6341-6341/? I/zygote: Not late-enabling -Xcheck:jni (already on)
2019-09-20 20:04:47.541 6341-6341/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void com.example.kak.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:17)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.os.Looper.loop() (Looper.java:164)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.kak-7pqLwDYU6E5fSFHEEZ0WoA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.kak-7pqLwDYU6E5fSFHEEZ0WoA==/lib/x86, /system/lib, /vendor/lib]]
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-09-20 20:04:47.663 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void com.example.kak.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:17)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.os.Looper.loop() (Looper.java:164)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2019-09-20 20:04:47.664 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void com.example.kak.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:17)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.os.Looper.loop() (Looper.java:164)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.kak-7pqLwDYU6E5fSFHEEZ0WoA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.kak-7pqLwDYU6E5fSFHEEZ0WoA==/lib/x86, /system/lib, /vendor/lib]]
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void com.example.kak.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:17)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
2019-09-20 20:04:47.665 6341-6341/com.example.kak I/zygote: at void android.os.Looper.loop() (Looper.java:164)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void com.example.kak.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:17)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.os.Looper.loop() (Looper.java:164)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
2019-09-20 20:04:47.666 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.kak-7pqLwDYU6E5fSFHEEZ0WoA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.kak-7pqLwDYU6E5fSFHEEZ0WoA==/lib/x86, /system/lib, /vendor/lib]]
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:93)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:379)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance0(java.lang.Object[]) (Constructor.java:-2)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:334)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:647)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:790)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:730)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:863)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:824)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:515)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:423)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:374)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void com.example.kak.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:17)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6975)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1213)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2770)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2892)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.-wrap11(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1593)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:105)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.os.Looper.loop() (Looper.java:164)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6541)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.Zygote$MethodAndArgsCaller.run() (Zygote.java:240)
2019-09-20 20:04:47.667 6341-6341/com.example.kak I/zygote: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:767)
2019-09-20 20:04:47.757 6341-6341/com.example.kak D/AndroidRuntime: Shutting down VM
2019-09-20 20:04:47.759 6341-6341/com.example.kak E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.kak, PID: 6341
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.kak/com.example.kak.MainActivity}: java.lang.NumberFormatException: For input string: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.Integer.parseInt(Integer.java:620)
at java.lang.Integer.parseInt(Integer.java:643)
at com.example.kak.MainActivity.onCreate(MainActivity.java:20)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
 
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="96dp"
android:layout_marginLeft="96dp"
android:layout_marginTop="144dp"
android:layout_marginEnd="102dp"
android:layout_marginRight="102dp"
android:layout_marginBottom="542dp"
android:ems="10"
android:hint="@String/age"
android:importantForAutofill="no"
android:inputType="number"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.571" />


</androidx.constraintlayout.widget.ConstraintLayout>
 
Did it crash after this line removed?

Java:
age = Integer.parseInt(editAge.getText().toString());
 
It crashed because int cannot hold an empty String. You can use TextWatcher to check the number entered by user.

Java:
public class MainActivity extends AppCompatActivity {
    String childBenefit;
    int age;
    TextView myTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        final EditText editAge = (EditText) findViewById(R.id.editText);
        myTextView = (TextView) findViewById(R.id.textview);

        editAge.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
                if (!editAge.getText().toString().equals("")) {
                    checkAge(Integer.parseInt(editAge.getText().toString()));
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                // TODO Auto-generated method stub
            }

        });
    }

    public void checkAge(int age) {
        if (age < 18) {
            childBenefit = "entitled to child benefit";
        } else {
            childBenefit = "no entitlement to child benefit";
        }
        myTextView.setText(childBenefit);
    }
}
 
Back
Top Bottom