converting hexadecimal to integer


Last Updated:

  1. vihaari71

    vihaari71 Member This Topic's Starter

    Joined:
    Nov 15, 2010
    Messages:
    5
    Likes Received:
    0
    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 Well-Known Member

    Joined:
    Oct 31, 2009
    Messages:
    7,112
    Likes Received:
    132
    Welcome to Android Forums!! :)
     
  3. Steven58

    Steven58 Reformed PH VIP Member

    Joined:
    Feb 19, 2010
    Messages:
    32,920
    Likes Received:
    25,271
    Welcome to Android Forums! I'll move this post to the Developer's section.
     
  4. tiring_day

    tiring_day Well-Known Member

    Joined:
    Mar 16, 2010
    Messages:
    62
    Likes Received:
    8
  5. satyamurthy_hyd

    satyamurthy_hyd New Member

    Joined:
    Jul 28, 2010
    Messages:
    4
    Likes Received:
    0
    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

    droidotheplains Member

    Joined:
    Nov 11, 2010
    Messages:
    15
    Likes Received:
    1
  7. vihaari71

    vihaari71 Member This Topic's Starter

    Joined:
    Nov 15, 2010
    Messages:
    5
    Likes Received:
    0
    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...