1. Download our Official Android App: Forums for Android!

Apps converting hexadecimal to integer

Discussion in 'Android Development' started by vihaari71, Nov 15, 2010.

  1. vihaari71

    vihaari71 Lurker
    Thread Starter
    Rank:
    None
    Points:
    25
    Posts:
    5
    Joined:
    Nov 15, 2010

    Nov 15, 2010
    5
    0
    25
    There is a problem to parse 0xFFFFFF88 into integer. can anyone help me to resolve this problem..

    The main issue is to render colors from database which are like #E7E9E7 with datatype as TEXT. I need to convert them as integer to use them in
    .mDrawable.getPaint().setColor(integer);

    Please help me out..

    Thanx in advance,
    Vihaari
     

    Advertisement

  2. bigdroid

    bigdroid Android Expert
    Rank:
    None
    Points:
    263
    Posts:
    7,118
    Joined:
    Oct 31, 2009

    Oct 31, 2009
    7,118
    138
    263
    Male
    Campus Safety Officer
    Earlville, NY
    Welcome to Android Forums!! :)
     
  3. Steven58

    Steven58 Reformed PH
    Rank:
     #3
    Points:
    3,933
    Posts:
    32,986
    Joined:
    Feb 19, 2010

    Feb 19, 2010
    32,986
    25,406
    3,933
    Male
    Welcome to Android Forums! I'll move this post to the Developer's section.
     
  4. tiring_day

    tiring_day Member
    Rank:
    None
    Points:
    36
    Posts:
    61
    Joined:
    Mar 16, 2010

    Mar 16, 2010
    61
    8
    36
  5. satyamurthy_hyd

    Rank:
    None
    Points:
    25
    Posts:
    4
    Joined:
    Jul 28, 2010

    Jul 28, 2010
    4
    0
    25
    Hi,
    I have Hexadecimal value and need to assign to a button's background by setBackgroundColor(),but getting Runtime Exception: see the code snippet below with exception output. Please help me resolve this

    String strColor="0xFFF3ECE0";
    int intColor= Integer.parseInt(strColor,16);
    button1.setBackgroundColor(intColor);

    ERROR/AndroidRuntime(874): java.lang.NumberFormatException: unable to parse '0xFFF3ECE0' as integer
     
  6. droidotheplains

    Rank:
    None
    Points:
    16
    Posts:
    15
    Joined:
    Nov 11, 2010

    Nov 11, 2010
    15
    1
    16
  7. vihaari71

    vihaari71 Lurker
    Thread Starter
    Rank:
    None
    Points:
    25
    Posts:
    5
    Joined:
    Nov 15, 2010

    Nov 15, 2010
    5
    0
    25
    Thanx for the support...

    I could solve the problem by just changing the values like if the value is #ffff00,
    i changed it to 0xffffff00..
    This is working as it is geting converted into decimal from haxadecimal..

    If any hexadecimal is there just add 0xff in the place of # to make it work as a decimal format one..
     

Share This Page

Loading...