Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26295] Android: Listview with template causes a nullpointer on itemclick

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-09-01T13:49:00.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelsandroid
ReporterZaedy Dantas Sayão
AssigneeGary Mathews
Created2018-08-13T17:47:30.000+0000
Updated2018-09-05T10:14:20.000+0000

Description

When you click on a listitem, using a Listview with template, it causes a nullpointer. It happens when you try to manipulate the items of a section. *Test case:* *index.xml*
<Alloy>
    <Window id="win">
        <ListView id="listView" backgroundColor="#fff">
            <Templates>
                <ItemTemplate name="menuItem">
                    <View bindId="item" height="50" backgroundColor="#24292e" color="#fff" onClick="onMenuItemClick">
                        <Label bindId="name" color="#fff"></Label>
                    </View>
                </ItemTemplate>
            </Templates>
            <ListSection />
        </ListView>
    </Window>
</Alloy>
------------------- *index.js*
function onMenuItemClick(e) {
    $.listView.sections[0].items = [];
}

var menuItems = [];

menuItems.push({
    name: {
        text: "A"
    },
    template: 'menuItem'
}, {
    name: {
        text: 'B'
    },
    template: 'menuItem'
}, {
    name: {
        text: "C"
    },
    template: 'menuItem'
}, {
    name: {
        text: "D"
    },
    template: 'menuItem'
});

$.listView.sections[0].items = menuItems;

$.win.open();

Attachments

FileDateSize
Screen Shot 2018-08-13 at 14.45.32.png2018-08-13T17:45:51.000+000049254

Comments

  1. Zaedy Dantas Sayão 2018-08-13

    I have a fix to the problem. I'll submit a PR after the issue has been moved to the correct project.
  2. Sharif AbuDarda 2018-08-13

    Hello, I have tested the issue and was able to reproduce it as described. I will forward this to our engineering. Please submit the PR. Thanks.
  3. Gary Mathews 2018-08-14

    master: https://github.com/appcelerator/titanium_mobile/pull/10251
  4. Josh Longton 2018-09-05

    *Closing ticket.* A nullpoint error is no longer thrown when an item in the listView is clicked. The fix is present in SDK: {noformat} 7.5.0.v20180904155047 {noformat} *ENV* {noformat} Pixel 2 XL (9.0) Emulator (8.1, 7.1.1) Appc NPM: 4.2.13 Appc CLI: 7.0.6 Ti CLI: 5.1.1 Node: 8.9.4 NPM: 6.3.0 {noformat}

JSON Source