Android Question App stopping on click

Discussion in 'Android Questions' started by Erfan Kakaei, Jul 18, 2019.

  1. Erfan Kakaei

    Erfan Kakaei New Member

    Hello,
    I was wondering if anyone could help me with this.
    My app compiles just fine, but when I click on any button within it, it just stops and exits.
    P.S: The only code within the mentioned buttons is to change the text inside a label.
    As in:
    Code:
    label.Text = "1"
     
  2. DonManfred

    DonManfred Expert Licensed User

    Check the log and post the full error. Without it is hard to give any advice.

    If you have a small testproject. Upload it. In the IDE use File->Export as zip and upload this zip.
     
    Erfan Kakaei likes this.
  3. mangojack

    mangojack Well-Known Member Licensed User

    I will take a wild shot ... Should the above code be Label1.Text = "1"

    If this does not solve you problem ... follow @DonManfred instructions so we can help you further .
     
    Erfan Kakaei likes this.
  4. Erfan Kakaei

    Erfan Kakaei New Member

    Well unfortunately I don't have access to the logs, but yes my project is small.
    Here it is:
     

    Attached Files:

  5. Erfan Kakaei

    Erfan Kakaei New Member

    Thank you sir, I just did.
     
  6. DonManfred

    DonManfred Expert Licensed User

    Connect your device with usb and use USB Debugging. It will list the log.
    The Error is "Empty String" in a math calculation
    In fact it is this code from you.
    Code:
    lblSum.Text = lblSum.Text + "0"
    lblSum is empty at start. You are trying to do a math operation here.
    add 0 to lblSum.Text.

    To concat the value of lblSum.Text and the 0 (when pressing Button "1" seems wrong to me.
    Code:
    lblSum.Text = lblSum.Text & "0"
    This was the case in all buttons.

    Please find a slightly changes example.
    i have changed
    - all occurances of
    Code:
    lblSum.Text = lblSum.Text + "0"
    with
    Code:
    lblSum.Text = lblSum.Text & "0"
    to concat the String.
    - all other numberbuttons other than the 0 to match the right number. You did used 0 in all...
     

    Attached Files:

    mangojack and Erfan Kakaei like this.
  7. Erfan Kakaei

    Erfan Kakaei New Member

    Thank you very much sir, it's been solved.
    Now could you please tell me how I can set a number variable to Null?
    For example let's say there's an integer with the value 4 inside it, and i'd like to have it empty as if it was just created.
    And is the method the same as setting a string to Null?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    A number variable can never be Null. It is also a mistake to set a string variable to null.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice