Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

ListView and how to style the background of search results

$
0
0

Ok, this ought to be fairly simple - but now I have tried out the different hacks I could think of, which apparently was not enough ;-)

For the purpose of this question I have created a simple page:

<Alloy>
    <Window backgroundColor="red" backButtonTitle="Retur">
        <ListView defaultItemTemplate="templateCountry" searchView="search">
            <SearchBar id="search"></SearchBar>
            <Templates>
                <ItemTemplate name="templateCountry" class="row">
                    <Label bindId="name" class="countryItem"/>
                </ItemTemplate>
            </Templates>
            <ListSection>
                <ListItem name:text="Test a1" searchableText="Test a1"></ListItem>
                <ListItem name:text="Test b2" searchableText="Test b2"></ListItem>
                <ListItem name:text="Test c3" searchableText="Test c3"></ListItem>
                <ListItem name:text="Test d4" searchableText="Test d4"></ListItem>
                <ListItem name:text="Test e5" searchableText="Test e5"></ListItem>
                <ListItem name:text="Test a6" searchableText="Test a6"></ListItem>
            </ListSection>
        </ListView>
    </Window>
</Alloy>
... and then I have a general style for Labels:
"Label":{
    backgroundColor: 'transparent',
    color:'white'
}
Now, the above page comes up in nice red background colour. All is good. Then try to enter "a" in the search bar... Now everything is white - no results. Well, after a little investigation it turns out that there in fact are two items found - but the text colour stays as white - and the background is turned white...!

Question is now, how can I identify the background of the search results view so I can control it?

The example here is a little simpler than the real world example - I could set the colour on the ListItem and that would work for the returned items - but the remaining part of the search results would still be white. In my real world example I need to make it transparent as I have an image in the background that needs to be visible.

I am using Studio 3.4.0GA, Alloy 1.5.1, Mac OSX 10.9.5 - and currently testing this for iOS (but will need it for Android as well). Tested in simulator and iPhone 5s - iOS 8.0.2


Viewing all articles
Browse latest Browse all 8068

Trending Articles