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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:58:47+00:00 2026-06-18T23:58:47+00:00

i have simple app using dialog for divided,subtraction,and etc with looping condition by operator

  • 0

i have simple app using dialog for divided,subtraction,and etc with looping condition by operator

my error

02-08 17:29:23.271: W/KeyCharacterMap(744): No keyboard for id 0
02-08 17:29:23.271: W/KeyCharacterMap(744): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
02-08 17:29:24.011: D/dalvikvm(744): GC_EXTERNAL_ALLOC freed 72K, 52% free 2611K/5379K, external 914K/1038K, paused 59ms
02-08 17:29:26.101: W/KeyCharacterMap(744): No keyboard for id 0
02-08 17:29:26.101: W/KeyCharacterMap(744): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
02-08 17:29:30.311: D/AndroidRuntime(744): Shutting down VM
02-08 17:29:30.311: W/dalvikvm(744): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-08 17:29:30.321: E/AndroidRuntime(744): FATAL EXCEPTION: main
02-08 17:29:30.321: E/AndroidRuntime(744): java.lang.NullPointerException
02-08 17:29:30.321: E/AndroidRuntime(744):  at com.example.dialog_looping.MainActivity$1$1$1.onClick(MainActivity.java:72)
02-08 17:29:30.321: E/AndroidRuntime(744):  at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159)
02-08 17:29:30.321: E/AndroidRuntime(744):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-08 17:29:30.321: E/AndroidRuntime(744):  at android.os.Looper.loop(Looper.java:123)
02-08 17:29:30.321: E/AndroidRuntime(744):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-08 17:29:30.321: E/AndroidRuntime(744):  at java.lang.reflect.Method.invokeNative(Native Method)
02-08 17:29:30.321: E/AndroidRuntime(744):  at java.lang.reflect.Method.invoke(Method.java:507)
02-08 17:29:30.321: E/AndroidRuntime(744):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-08 17:29:30.321: E/AndroidRuntime(744):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-08 17:29:30.321: E/AndroidRuntime(744):  at dalvik.system.NativeStart.main(Native Method)
02-08 17:34:30.490: I/Process(744): Sending signal. PID: 744 SIG: 9

this is my full code use dialog looping for subtraction,divided and etc….

public class MainActivity extends Activity {
    int result=0,i;
    int [] arr;
    int indexArray = 0;
    String Oprtr;
    RadioGroup operator_mode;
    RadioButton rb;
    @Override  
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        final LayoutInflater inflater = this.getLayoutInflater();
        final View v=inflater.inflate(R.layout.dialoginput, null);

        operator_mode=(RadioGroup)findViewById(R.id.operator);


        //operator_mode.setOnClickListener(l)(null);

        new AlertDialog.Builder(MainActivity.this)
            .setIcon(R.drawable.ic_launcher)
            .setTitle("Total Operator")
            .setView(v)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {

                 public void onClick(final DialogInterface dialog, int whichButton) {
                      EditText op = (EditText)v.findViewById(R.id.operator);
                      arr=new int [Integer.valueOf(op.getText().toString())+1];
                      for (i = 0;i<arr.length;i++){


                            LayoutInflater inflater = MainActivity.this.getLayoutInflater();
                            final View v2=inflater.inflate(R.layout.input, null) ;

                            new AlertDialog.Builder(MainActivity.this)
                                .setIcon(R.drawable.ic_launcher)
                                .setTitle("number:")
                                .setView(v2)
                                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sumthin) {

                                        EditText number = (EditText)v2.findViewById(R.id.number);
                                        arr[indexArray]= Integer.valueOf(number.getText().toString());
                                        //Log.v ("aa",Integer.toString(arr[indexArray]));

                                        LayoutInflater inflater = MainActivity.this.getLayoutInflater();
                                        final View v3=inflater.inflate(R.layout.operator, null) ;

                                        new AlertDialog.Builder(MainActivity.this)
                                        .setIcon(R.drawable.ic_launcher)
                                        .setTitle("select Operator:")
                                        .setView(v3)
                                        .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dlg, int sumthin) {
                                                sumthin = operator_mode.getCheckedRadioButtonId();
                                                rb = (RadioButton) findViewById(sumthin);
                                                switch(sumthin){
                                                case R.id.plus:
                                                    Oprtr = "+";
                                                    Log.v ("aa",Oprtr);
                                                    /*
                                                    if (indexArray==0){
                                                        result = arr[indexArray];
                                                        if (result<0){
                                                            new AlertDialog.Builder(MainActivity.this)
                                                                .setTitle("Error")
                                                                .setMessage("result can't negative value")
                                                                .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                                                                    public void onClick(DialogInterface dlg, int sumthin) {
                                                                        finish();
                                                                    }
                                                                })
                                                                .show();
                                                            } else if (result>9999999){
                                                                new AlertDialog.Builder(MainActivity.this)
                                                                .setTitle("Error")
                                                                .setMessage("result can't > 9999999")
                                                                .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                                                                    public void onClick(DialogInterface dlg, int sumthin) {
                                                                        finish();
                                                                    }
                                                                })
                                                                .show();
                                                            }else {
                                                                new AlertDialog.Builder(MainActivity.this)
                                                                .setTitle("result")
                                                                .setMessage(Integer.toString(result))
                                                                .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                                                                    public void onClick(DialogInterface dlg, int sumthin) {
                                                                    }
                                                                })
                                                                .show();
                                                            }
                                                    } else {
                                                            result = result + arr[indexArray];
                                                            if (result<0){
                                                            new AlertDialog.Builder(MainActivity.this)
                                                                .setTitle("Error")
                                                                .setMessage("result can't negative value")
                                                                .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                                                                    public void onClick(DialogInterface dlg, int sumthin) {
                                                                        finish();
                                                                    }
                                                                })
                                                                .show();
                                                            } else if (result>9999999){
                                                                new AlertDialog.Builder(MainActivity.this)
                                                                .setTitle("Error")
                                                                .setMessage("result can't > 9999999")
                                                                .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                                                                    public void onClick(DialogInterface dlg, int sumthin) {
                                                                        finish();
                                                                    }
                                                                })
                                                                .show();
                                                            }else {
                                                                new AlertDialog.Builder(MainActivity.this)
                                                                .setTitle("result")
                                                                .setMessage(Integer.toString(result))
                                                                .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                                                                    public void onClick(DialogInterface dlg, int sumthin) {
                                                                    }
                                                                })
                                                                .show();
                                                            }
                                                    }                                   
                                                    indexArray++;
                                                    */
                                                    break;
                                                case R.id.minus:
                                                    //str="Meeting Mode";
                                                    break;
                                                case R.id.substract:
                                                    //str="Silent Mode";
                                                    break;
                                                case R.id.divide:
                                                    //str="Offline Mode";
                                                    break;
                                            }
                                            }
                                        })
                                        .show();
                                    }
                                })
                                .show();
                        }
                 }
            })

            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
                 finish();
              }
            })
            .show();
    }
}

where the error with my code?

please help me.thanks

  • 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-18T23:58:48+00:00Added an answer on June 18, 2026 at 11:58 pm

    Your RadioGroup is null, I believe. You need to set your view with

    setContentView(R.layout.your_view)

    Then if you need to inflate a view use:

    operator_mode=(RadioGroup)v.findViewById(R.id.operator);

    instead of

    operator_mode=(RadioGroup)findViewById(R.id.operator);

    Edit

    You can use your inflater but you would have to do something like:

    Window window = getWindow();
    
        window.setContentView(v);`
    

    But you are still calling setContentView()

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

Sidebar

Related Questions

I have created a simple web app/form using google app engine. the site is
I have a simple app written using SQL Server, Entity Framework, C# and WCF.
I have a simple console app using SQL Compact 4.0 and entity frameworks 4.
I have a simple rails app using devise--as such (and being a new rails
I have created a simple app using storyboard. In storyboard file, i have dragged
I have a sample app using CoreData, and am now ready to convert my
This is a real newbie question. I have simple app that selects a picture
I have simple Sinatra app. web.rb: require 'sinatra' get '/' do Hello end Gemfile:*
I have a simple app where you can login it looks like this: {{#view
I have a simple app with a full screen UIWebView. This contains HTML generated

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.