开发者

Error passing variables from arrays to be displayed in an android application

开发者 https://www.devze.com 2023-03-10 17:11 出处:网络
Im trying to pass variable that i am storing in an array in an android application so they can be displayed on the screen and i keep receiving a null pointer exception

Im trying to pass variable that i am storing in an array in an android application so they can be displayed on the screen and i keep receiving a null pointer exception this is开发者_JS百科 the error i keep getting

ViewRoot.handleMessage(Message) line: 1704  
ViewRoot(Handler).dispatchMessage(Message) line: 99

and this is the code to pass an array of integers which refer to string variables in my R which I would like to randomly display on a radiobutton. there are 20 elements

public void createQuestion()
{
    int temp =(int)Math.floor(Math.random()*20);
    RB1.setText(plantN[temp]);\\this is where the nullpointer is originating
}

similarly I was trying to do the same thing but instead pass an array of drawables to an imageview and i was recieving the same error any suggestions would be greatly appreciated


So either RB1 is null, or plantN[temp] is null. Or even plantN itself. Try debugging which is null, just have it log whether or not that certain object is null, and go from there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号