Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CommonLayoutParams cannot be cast to android.widget.AbsListView #1710

@sitefinitysteve

Description

@sitefinitysteve

Please, provide the details below:

Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?

Yes

Tell us about the problem

Please, ensure your title is less than 63 characters long and starts with a capital
letter.

So this all works on iOS, the usecase is items in a listview can be clicked, in the client event I change the the class of an object in the listview, and then the text of a label. In iOS, it selects, on android the code runs, but right after my method the app crashes with this error:

Error

java.lang.ClassCastException: org.nativescript.widgets.CommonLayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
at android.widget.AbsListView$RecycleBin.fillActiveViews(AbsListView.java:8584)
at android.widget.ListView.layoutChildren(ListView.java:1665)
at android.widget.AbsListView.onLayout(AbsListView.java:2640)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:189)
at org.nativescript.widgets.GridLayout.onLayout(GridLayout.java:353)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1684)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:189)
at org.nativescript.widgets.GridLayout.onLayout(GridLayout.java:353)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:189)
at org.nativescript.widgets.GridLayout.onLayout(GridLayout.java:353)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at org.nativescript.widgets.CommonLayoutParams.layoutChild(CommonLayoutParams.java:189)
at org.nativescript.widgets.GridLayout.onLayout(GridLayout.java:353)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:16922)
at android.view.ViewGroup.layout(ViewGroup.java:5405)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2413)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2122)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1264)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6944)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6837)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

{
  "name": "tns-core-modules",
  "description": "Telerik NativeScript Core Modules",
  "version": "1.6.0",
  "homepage": "https://www.nativescript.org",
  "repository": {
    "type": "git",
    "url": "https://github.com/NativeScript/NativeScript/commit/185b4c2480d8b08b569d23ebc1e533f684e434a4"
  },
  "files": [
    "**/*.*",
    "**/*",
    "!.baseDir.*",
    "!node-tests/",
    "!apps/"
  ],
  "license": "Apache-2.0",
  "devDependencies": {
    "chai": "3.2.0",
    "grunt": "0.4.5",
    "grunt-contrib-clean": "0.6.0",
    "grunt-contrib-copy": "git+https://github.com/ErjanGavalji/grunt-contrib-copy.git#1c976a133210be4ce8c96313f5daf14833f7f8f9",
    "grunt-env": "0.4.4",
    "grunt-exec": "0.4.6",
    "grunt-mkdir": "0.1.2",
    "grunt-multi-dest": "1.0.0",
    "grunt-shell": "1.1.2",
    "grunt-simple-mocha": "0.4.0",
    "grunt-ts": "5.3.2",
    "grunt-typedoc": "0.2.3",
    "grunt-untar": "0.0.1",
    "mocha": "2.2.5",
    "shelljs": "0.5.3",
    "grunt-tslint": "3.0.0",
    "time-grunt": "^1.3.0",
    "tslint": "3.3.0",
    "typescript": "1.7.5"
  },
  "typings": "tns-core-modules.d.ts",
  "dependencies": {
    "tns-core-modules-widgets": "1.6.1"
  },
  "nativescript": {
    "platforms": {
      "ios": "1.6.0",
      "android": "1.6.0"
    }
  },
  "_id": "[email protected]",
  "_shasum": "2497836382c9857f2dea8e8a7ab59d8c284169a2",
  "_resolved": "https://registry.npmjs.org/tns-core-modules/-/tns-core-modules-1.6.0.tgz",
  "_from": "tns-core-modules@latest",
  "scripts": {},
  "_npmVersion": "2.14.7",
  "_nodeVersion": "4.2.2",
  "_npmUser": {
    "name": "enchev",
    "email": "[email protected]"
  },
  "dist": {
    "shasum": "2497836382c9857f2dea8e8a7ab59d8c284169a2",
    "tarball": "http://registry.npmjs.org/tns-core-modules/-/tns-core-modules-1.6.0.tgz"
  },
  "maintainers": [
    {
      "name": "enchev",
      "email": "[email protected]"
    },
    {
      "name": "erjangavalji",
      "email": "[email protected]"
    },
    {
      "name": "fatme",
      "email": "[email protected]"
    },
    {
      "name": "hdeshev",
      "email": "[email protected]"
    },
    {
      "name": "ligaz",
      "email": "[email protected]"
    },
    {
      "name": "nsndeck",
      "email": "[email protected]"
    },
    {
      "name": "sdobrev",
      "email": "[email protected]"
    },
    {
      "name": "valio.stoychev",
      "email": "[email protected]"
    }
  ],
  "_npmOperationalInternal": {
    "host": "packages-5-east.internal.npmjs.com",
    "tmp": "tmp/tns-core-modules-1.6.0.tgz_1455717250557_0.07532842340879142"
  },
  "directories": {}
}

Please tell us how to recreate the issue in as much detail as possible.

https://www.dropbox.com/s/ycsfxn1ezqadp5x/OutbreakHelp.zip?dl=0
In the app: Resources->FilterFAB->Categories-> pick anything
In the code: app/views/resources/filter/filter.js line around line 107... this code all WORKS, the crashing happens after it runs.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

<GridLayout rows="auto, *" columns="*">
                            <Label row="0" text="Topics" textWrap="false" class="type-header" />
                            <ListView row="1"  id="categoryRepeater" items="{{ topics }}" itemTap="onCategoryTap">
                                <ListView.itemTemplate>
                                    <StackLayout class="{{ IsSelected ? 'filter-item-selected' : 'filter-item' }}" tap="onCategoryTap">
                                    <StackLayout class="{{ IsChild ? 'filter-child' : '' }}">
                                            <GridLayout rows="*" columns="30, *">
                                                <Label row="0" col="0" text="{{ IsSelected ? '&#xe834;' : '&#xe835;' }}" class="selection-icon" />
                                                <Label row="0" col="1" text="{{ Title }}" class="text" />
                                            </GridLayout>
                                    </StackLayout>
                                    <StackLayout class="{{ IsSelected ? 'filter-bottom-selected' : 'filter-bottom' }}" />
                                    </StackLayout>
                                </ListView.itemTemplate>
                            </ListView>
                        </GridLayout>
exports.onCategoryTap = function(args){
    selectListItem(args, "categoryRepeater");
}

function selectListItem(args, repeaterId){
    var stack = args.object;
    var item = stack.bindingContext;
    item.IsSelected = (item.IsSelected) ? false : true;
    stack.cssClass = (item.IsSelected) ? "filter-item-selected" : "filter-item";

    var icon = stack.getElementsByClassName("selection-icon")[0];

    if(appModule.ios){
        icon.fadeOut(1).then(function(){
            if(item.IsSelected){
                icon.text = "\uE834"

            }else{
                icon.text = "\uE835"
            }

            icon.fadeIn(30);
        });
    }else{
        if(item.IsSelected){
            icon.text = "\uE834"

        }else{
            icon.text = "\uE835"
        }
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions