java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference

Appcelerator JIRA | Ángel Flores | 1 year ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    I want to mark a row of a table as selected using a border. Given that the border does not work at all if it is set in the tableViewRow, I tried it using an inner view. If I try to modify the color of the view border without setting first in the constructor, an exception is thrown. {code:java} var table = Ti.UI.createTableView({id:"table", top:10, width:Ti.UI.FILL, height:Ti.UI.SIZE, backgroundColor: Config.BACKGROUND_COLOR_LIST, scrollable:true, separatorColor:"white", title: {font:{fontWeight:'bold'}}}); var row = Ti.UI.createTableViewRow({id: Math.random(), width:Ti.UI.FILL, height:Ti.UI.SIZE, layout: "horizontal", backgroundFocusedColor: Config.MAIN_COLOR, chosen:false}); var borderView=Ti.UI.createView({width:Ti.UI.SIZE, height:Ti.UI.SIZE, layout: "horizontal", /*borderColor:Config.BUTTON_COLOR, */borderWidth:0}); var logo = Ti.UI.createImageView({width:"20%", height:Ti.UI.SIZE, image: '/appicon.png', defaultImage: '/appicon.png'}); var content= Ti.UI.createView({width:"80%", height:Ti.UI.SIZE}); ... ... ... row.addEventListener("click", rowClickEvent(row.id)); function rowClickEvent(rowId) { return function() { var dataRows = table.data[0].rows; for(i=0;i<dataRows.length;i++) { var item = dataRows[i]; var borderView = item.children[0]; if(rowId == item.id) { item.chosen= !item.chosen; button.disabled = !item.chosen; if(item.chosen) { Ti.API.info("Selecting the row..."); borderView.borderColor=Config.BUTTON_COLOR;//<-----it throws an exception borderView.borderWidth = '5dp'; } else { Ti.API.info("Unselecting the row..."); borderView.borderColor=Config.BACKGROUND_COLOR_LIST;//<-----it throws an exception borderView.borderWidth = 0; } } else if(item.chosen && (rowId != item.id))//avoid the blink { Ti.API.info("Unselecting the row..."); borderView.borderColor = Config.BACKGROUND_COLOR_LIST;//<-----it throws an exception borderView.borderWidth = 0; item.chosen=false; } } }; } [ERROR] : TiApplication: (main) [12903,12903] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference; Titanium 4.0.0,2015/05/18 15:42,9239ff9 [ERROR] : TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference [ERROR] : TiApplication: at org.appcelerator.titanium.view.TiUIView.handleBorderProperty(TiUIView.java:1269) [ERROR] : TiApplication: at org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:842) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1083) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:135) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5538) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) {code}

    Appcelerator JIRA | 1 year ago | Ángel Flores
    java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference
  2. 0

    I want to mark a row of a table as selected using a border. Given that the border does not work at all if it is set in the tableViewRow, I tried it using an inner view. If I try to modify the color of the view border without setting first in the constructor, an exception is thrown. {code:java} var table = Ti.UI.createTableView({id:"table", top:10, width:Ti.UI.FILL, height:Ti.UI.SIZE, backgroundColor: Config.BACKGROUND_COLOR_LIST, scrollable:true, separatorColor:"white", title: {font:{fontWeight:'bold'}}}); var row = Ti.UI.createTableViewRow({id: Math.random(), width:Ti.UI.FILL, height:Ti.UI.SIZE, layout: "horizontal", backgroundFocusedColor: Config.MAIN_COLOR, chosen:false}); var borderView=Ti.UI.createView({width:Ti.UI.SIZE, height:Ti.UI.SIZE, layout: "horizontal", /*borderColor:Config.BUTTON_COLOR, */borderWidth:0}); var logo = Ti.UI.createImageView({width:"20%", height:Ti.UI.SIZE, image: '/appicon.png', defaultImage: '/appicon.png'}); var content= Ti.UI.createView({width:"80%", height:Ti.UI.SIZE}); ... ... ... row.addEventListener("click", rowClickEvent(row.id)); function rowClickEvent(rowId) { return function() { var dataRows = table.data[0].rows; for(i=0;i<dataRows.length;i++) { var item = dataRows[i]; var borderView = item.children[0]; if(rowId == item.id) { item.chosen= !item.chosen; button.disabled = !item.chosen; if(item.chosen) { Ti.API.info("Selecting the row..."); borderView.borderColor=Config.BUTTON_COLOR;//<-----it throws an exception borderView.borderWidth = '5dp'; } else { Ti.API.info("Unselecting the row..."); borderView.borderColor=Config.BACKGROUND_COLOR_LIST;//<-----it throws an exception borderView.borderWidth = 0; } } else if(item.chosen && (rowId != item.id))//avoid the blink { Ti.API.info("Unselecting the row..."); borderView.borderColor = Config.BACKGROUND_COLOR_LIST;//<-----it throws an exception borderView.borderWidth = 0; item.chosen=false; } } }; } [ERROR] : TiApplication: (main) [12903,12903] Sending event: exception on thread: main msg:java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference; Titanium 4.0.0,2015/05/18 15:42,9239ff9 [ERROR] : TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference [ERROR] : TiApplication: at org.appcelerator.titanium.view.TiUIView.handleBorderProperty(TiUIView.java:1269) [ERROR] : TiApplication: at org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:842) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1083) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:135) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5538) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:372) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) {code}

    Appcelerator JIRA | 1 year ago | Ángel Flores
    java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'void org.appcelerator.titanium.view.TiBorderWrapperView.setColor(int)' on a null object reference

      at org.appcelerator.titanium.view.TiUIView.handleBorderProperty()
    2. org.appcelerator.titanium
      TiUIView.propertyChanged
      1. org.appcelerator.titanium.view.TiUIView.handleBorderProperty(TiUIView.java:1269)
      2. org.appcelerator.titanium.view.TiUIView.propertyChanged(TiUIView.java:842)
      2 frames
    3. org.appcelerator.kroll
      KrollProxy.handleMessage
      1. org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
      2. org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1083)
      2 frames
    4. org.appcelerator.titanium
      TiViewProxy.handleMessage
      1. org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:347)
      1 frame
    5. Android Platform
      ActivityThread.main
      1. android.os.Handler.dispatchMessage(Handler.java:98)
      2. android.os.Looper.loop(Looper.java:135)
      3. android.app.ActivityThread.main(ActivityThread.java:5538)
      3 frames
    6. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    7. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
      2 frames