Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6977423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:37:26+00:00 2026-05-27T17:37:26+00:00

Im very new to java (mainly duel with embedded only) Im writing a simple

  • 0

Im very new to java (mainly duel with embedded only)

Im writing a simple android program that passes a value of editText input to another editText by a click of a button. However every-time I hit the button my program crashes. would like anybody comments 🙂

This is my main:

package Mushroom.Pickers.Note;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
//import android.widget.Button;
//import android.widget.TableLayout;

public class Mushy extends Activity {
//private TableLayout layout;
//private Button button;

/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);      
}   

public void Compute_data(View view) {//Function to perform on click
     //Perform calculation      
     int Hours;
     EditText start_time = (EditText)findViewById(R.id.editText26) ;
     Hours = Integer.parseInt(start_time.getText().toString());     

     EditText test_time = (EditText)findViewById(R.id.editText43);
     test_time.setText(Hours);

 }  
}

and in my xml:

<Button
        android:id="@+id/Button1"
        android:layout_width="134px"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:textSize="15sp"
        android:text="Calculate"
        android:onClick="Compute_data" 
        android:textColor="#1e90ff" />
</TableRow>
<EditText
        android:id="@+id/editText26"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:inputType="number"
        android:width="350px" />

<EditText
        android:id="@+id/editText43"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical|center_horizontal"
        android:inputType="number"
        android:width="350px" />

The layout appears fine, just the matter of crashing when the button is clicked 🙁

P/S: here is the logcat:

12-19 03:03:02.106: W/ResourceType(667): No package identifier when getting value for resource number 0x00000004
12-19 03:03:02.106: D/AndroidRuntime(667): Shutting down VM
12-19 03:03:02.106: W/dalvikvm(667): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-19 03:03:02.275: E/AndroidRuntime(667): FATAL EXCEPTION: main
12-19 03:03:02.275: E/AndroidRuntime(667): java.lang.IllegalStateException: Could not execute method of the activity
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.view.View$1.onClick(View.java:3039)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.view.View.performClick(View.java:3480)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.view.View$PerformClick.run(View.java:13983)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.os.Handler.handleCallback(Handler.java:605)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.os.Handler.dispatchMessage(Handler.java:92)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.os.Looper.loop(Looper.java:137)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.app.ActivityThread.main(ActivityThread.java:4340)
12-19 03:03:02.275: E/AndroidRuntime(667):  at java.lang.reflect.Method.invokeNative(Native Method)
12-19 03:03:02.275: E/AndroidRuntime(667):  at java.lang.reflect.Method.invoke(Method.java:511)
12-19 03:03:02.275: E/AndroidRuntime(667):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-19 03:03:02.275: E/AndroidRuntime(667):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-19 03:03:02.275: E/AndroidRuntime(667):  at dalvik.system.NativeStart.main(Native Method)
12-19 03:03:02.275: E/AndroidRuntime(667): Caused by: java.lang.reflect.InvocationTargetException
12-19 03:03:02.275: E/AndroidRuntime(667):  at java.lang.reflect.Method.invokeNative(Native Method)
12-19 03:03:02.275: E/AndroidRuntime(667):  at java.lang.reflect.Method.invoke(Method.java:511)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.view.View$1.onClick(View.java:3034)
12-19 03:03:02.275: E/AndroidRuntime(667):  ... 11 more
12-19 03:03:02.275: E/AndroidRuntime(667): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x4
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.content.res.Resources.getText(Resources.java:247)
12-19 03:03:02.275: E/AndroidRuntime(667):  at android.widget.TextView.setText(TextView.java:3428)
12-19 03:03:02.275: E/AndroidRuntime(667):  at Mushroom.Pickers.Note.Mushy.Compute_data(Mushy.java:29)
12-19 03:03:02.275: E/AndroidRuntime(667):  ... 14 more
12-19 03:03:02.475: D/dalvikvm(667): GC_CONCURRENT freed 230K, 4% free 10426K/10759K, paused 6ms+14ms
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:37:27+00:00Added an answer on May 27, 2026 at 5:37 pm

    Problem:

    test_time.setText(value) have overridden methods of both int and String parameters.

    • int parameter indicate that you will pass String resource id. (i.e
      R.string.any_string)
    • String parameter indicate that you will pass String.

    you were passing Hours as int not as String.

    Solution:

    you will convet int to String to set as text of any View (i.e Button, TextView, EditText)
    Modify your code as below:

    public void Compute_data(View view) {
         //....
         //here is rest of your code
         EditText test_time = (EditText)findViewById(R.id.editText43);
         test_time.setText(String.valueOf(Hours));//<<<------consider this change
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to JAVA. I have written simple program (in Linux -VIM
I am really new to Java and I read that synchronized is very expensive
I am very new to Java as well as Android programming. I was attempting
I am very new to java and trying to develop an Android app called
ok so im very new to android development and fairly new to java and
I'm very new to developing on Android and the Java language in general and
I am very new to Java Me (first time). I want my program to
I'm very new to Java and the Android SDK but I'm almost done with
I am very new to java and only start to use Eclipse to run
I am very new to Java and also Real Time Program. I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.