Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
Individual cell background on IGGridView
posted

Hi,

I am trying to set different background colors according to the text in the cell within a column. (ex: green for "Yes" and red for "No") The following sets the color for the entire column:

IGTextColumn statusColumn = new IGTextColumn("status");
statusColumn.setBackgroundColor(android.graphics.Color.GREEN);

Can you please provide with a simple example how to achieve this?

Thanks

  • 34510
    Verified Answer
    Offline posted

    Hi Elton,

    What you are looking for is conditional formatting.  The best way to do this with the IGGridView is by creating a custom IGColumnDefinition class and overriding the getCell method.  Inside this method you can get the cell and based on the cell value you can set the cell's background color.  I have attached a sample that demonstrates this.  The code you want to look at is in YesNoColumn.java.  You should also look at CustomTextCell.java as well.  My grid is defined in MainActivity.java.

    Let me know if you have any questions.

    AndroidIGGridSample2.zip