converting hexadecimal to integer

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

  1. vihaari71

    vihaari71 Member
    25

    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 Well-Known Member
    163

    Oct 31, 2009
    7,115
    134
    163
    Campus Safety Officer
    Earlville, NY
    Welcome to Android Forums!! :)
     
  3. Steven58

    Steven58 Reformed PH
    VIP Member
    3,833

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

    tiring_day Well-Known Member
    36

    Mar 16, 2010
    62
    8
    36
  5. satyamurthy_hyd

    satyamurthy_hyd New Member
    25

    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. vihaari71

    vihaari71 Member
    25

    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...