0
I’m making a test application that has 1 Edit and a textview , Edit text will have a value within the initial 0 , when you click the textview , I want it to increase to 10.00 , and if you click again increase to 20 , and so on
teste = findViewById(R.id.add10);
teste2 = findViewById(R.id.editText);
teste.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int a=Integer.parseInt(teste2.getText().toString());
int b=a+10;
teste2.setText(new Integer(b).toString());
}
});
}
}
Segue logcat
01-22 10:23:48.987 8645-8645/com.example.gabriel.teste E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /vendor/lib]]
01-22 10:23:49.100 8645-8645/com.example.gabriel.teste E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.gabriel.teste, PID: 8645
java.lang.NumberFormatException: For input string: "Name"
at java.lang.Integer.parseInt(Integer.java:521)
at java.lang.Integer.parseInt(Integer.java:556)
at com.example.gabriel.teste.MainActivity$1.onClick(MainActivity.java:25)
at android.view.View.performClick(View.java:6261)
at android.widget.TextView.performClick(TextView.java:11159)
at android.view.View$PerformClick.run(View.java:23748)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
It did not work out is a little vague. Did not run ? Gave error ? Did not do anything ? Did not add the amount that was supposed ? Try to be a little more specific in the problem you have.
– Isac
Be more specific about the error that occurred, and pass on more information to help us help you.
– Grupo CDS Informática
Guys , I put the logcat in the question
– Paiva
What value are you passing in textview and edittext?
– Antonio S. Junior
@Antonios.Junior 10
– Paiva
This error happens when you pass some null value or parse cannot convert. It seems to me that you have some string "Name" in your app and he is trying to convert to Integer.
– Antonio S. Junior
@Antonios.Junior thank you , the error was because Edit had the name value , I managed to solve
– Paiva
good! I’ll just add as an answer to serve other people who have the same problem.
– Antonio S. Junior