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 8922109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:45:00+00:00 2026-06-15T06:45:00+00:00

I’m new to android programming and building my first app.It is supposed to display

  • 0

I’m new to android programming and building my first app.It is supposed to display a message about two numbers, based on what is selected in a RadioGroup.My problem is that i keep getting errors when clicking the “find out” button, which are related to onClick.

public void onCheckedChanged(RadioGroup radio, int checkedId) {
    count = checkedId;
}
public void executa(View v){
       RadioButton radioButton1=(RadioButton) findViewById(R.id.radioButton1);
       RadioButton radioButton2=(RadioButton) findViewById(R.id.radioButton2);
       RadioButton radioButton3=(RadioButton) findViewById(R.id.radioButton3);
       RadioButton radioButton4=(RadioButton) findViewById(R.id.radioButton4);
       Button button=(Button) findViewById(R.id.button); 
     RadioGroup radio=(RadioGroup) findViewById(R.id.radio);
    if (v.getId() == R.id.button){
    count = radio.getCheckedRadioButtonId();
    EditText editText1 = (EditText) findViewById(R.id.Text1);
       int nr1=Integer.getInteger(editText1.getText().toString());  
       EditText editText2 = (EditText) findViewById(R.id.Text2);
       int nr2=Integer.getInteger(editText2.getText().toString());  

       pozitive=0;

       negative=0;

       if (nr1==nr2) max=min=-1; else
       if (nr1>nr2){  max=nr1;
                                   min=nr2;}
       else {  max=nr2;
           min=nr1;}
      if (nr1>0) pozitive++;
                else negative--;
      if (nr2>0) pozitive++;
        else negative--;

    Intent intent=new Intent(this,Raspuns.class);
    switch(count){
    case 1:intent.putExtra(Valoare, max);
    break;
    case 2:intent.putExtra(Valoare, min);
    break;
    case 3:intent.putExtra(Valoare, pozitive);
    break;
    case 4:intent.putExtra(Valoare, negative);
    break;
    }
    startActivity(intent);  
}
}
 @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);


 }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return false;
        }

}

Also,the message is sent via an intent to a second activity,called from executa,by clicking the afla button.Thanks for any advice!
EDIT:logcat:

12-02 00:12:11.788: E/AndroidRuntime(3524): FATAL EXCEPTION: main
12-02 00:12:11.788: E/AndroidRuntime(3524): java.lang.IllegalStateException: Could not execute method of the activity
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.view.View$1.onClick(View.java:3044)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.view.View.performClick(View.java:3511)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.view.View$PerformClick.run(View.java:14109)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.os.Handler.handleCallback(Handler.java:605)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.os.Looper.loop(Looper.java:137)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.app.ActivityThread.main(ActivityThread.java:4424)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at java.lang.reflect.Method.invokeNative(Native Method)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at java.lang.reflect.Method.invoke(Method.java:511)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at dalvik.system.NativeStart.main(Native Method)
12-02 00:12:11.788: E/AndroidRuntime(3524): Caused by: java.lang.reflect.InvocationTargetException
12-02 00:12:11.788: E/AndroidRuntime(3524):     at java.lang.reflect.Method.invokeNative(Native Method)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at java.lang.reflect.Method.invoke(Method.java:511)
12-02 00:12:11.788: E/AndroidRuntime(3524):     at android.view.View$1.onClick(View.java:3039)
12-02 00:12:11.788: E/AndroidRuntime(3524):     ... 11 more
12-02 00:12:11.788: E/AndroidRuntime(3524): Caused by: java.lang.NullPointerException
12-02 00:12:11.788: E/AndroidRuntime(3524):     at com.example.myfirstrealandroidapp.MainActivity.executa(MainActivity.java:48)
12-02 00:12:11.788: E/AndroidRuntime(3524):     ... 14 more
  • 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-06-15T06:45:01+00:00Added an answer on June 15, 2026 at 6:45 am

    Thanks for the input! It seems the error of my app was that i used "Integer.getInt” instead of “Integer.parseInt". Also,it gave the correct answer when i used the radio listener and button

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a small JavaScript validation script that validates inputs based on Regex. I
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.