2016-12-26 65 views
0

我正在使用nativescript版本2.4.2。 Android中的標籤會產生漣漪效應,但當我在可點擊的網格佈局下使用標籤時,紋波不會發生。gridlayout內的Nativescript標籤沒有獲得漣漪效應

考慮下面的代碼

<StackLayout text="fill"> 
     <ListView [items]="groceryList | async | searchFilter:sb.text" class="listview"> 

    <template let-item="item" col="0"> 
     <GridLayout columns="auto,auto,*" rows="*,*" class="fa" (tap)="goToList(item)"> 
     <Label horizontalAlignment="left" verticalAlignment="center" [text]="item.iconFont | fonticon" class="h2 icon-thumbnail"></Label> 
     <Label col="1" horizontalAlignment="center" [text]="item.name" class="listview item "></Label> 
     <Label col="2" horizontalAlignment="right" text="&#xf105;" class="listview item" class="h2 arrow-icon "></Label> 

     </GridLayout> 
    </template> 

    </ListView> 
</StackLayout> 

請注意,我在GridView上有(tap)="goToList(item)"。刪除點擊事件綁定使其工作。

回答

1

由於您的GridLasyout基本上是您的物品模板的容器,爲什麼不使用內置itemTap作爲列表視圖項目,而不是爲內部容器創建自己的tap。

<ListView col="0" [items]="groceryList" (itemTap)="goToList($event)"> 
    <template let-item="item"> 
     <GridLayout columns="auto,auto,*" rows="*,*" class="fa"> 
     <Label col="2" horizontalAlignment="right" text="&#xf105;"></Label> 
     </GridLayout> 
    </template> 

,從這裏,你可以使用與$事件傳來的參數 例如

public goToList(args) { 
    console.log("Item Tapped at cell index: " + args.index); 
    // use the index to navigate to this item 
} 

完整的示例here

+1

是的,這works..Thanks – krv