349 views
in System Integration by

Hi,

I want to change my object icon depend on the device data.

below is my code

var int32 tmp = 0;
native(tmp)
{
  if(current->data.fattrib & AM_DIR)
  {
  	tmp = 1; 
  }
  else
  {
  	tmp = 0;
  }
}
if(tmp == 0)
{itemView.Icon = ImageResource::list;}
else
{itemView.Icon = ImageResource::ship;}

I need to do if else twice.

Is there anyway to do better ?

 

Best Regards

Andy Dong 

1 Answer

0 votes
by
 
Best answer

Hello Andy,

I would implement following code:

var bool tmp = false;

native(tmp)
{
  tmp = ( current->data.fattrib & AM_DIR ) != 0;
}

if ( tmp == false )
  itemView.Icon = ImageResource::list;
else
  itemView.Icon = ImageResource::ship;

Does it help you?

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...