从数组中传递变量以在android应用程序中显示时出错

从数组中传递变量以在android应用程序中显示时出错,android,arrays,string,nullpointerexception,drawable,Android,Arrays,String,Nullpointerexception,Drawable,我试图传递我存储在android应用程序数组中的变量,以便它们可以显示在屏幕上,并且我一直收到空指针异常 这就是我一直犯的错误 ViewRoot.handleMessage(Message) line: 1704 ViewRoot(Handler).dispatchMessage(Message) line: 99 这是传递一个整数数组的代码,它引用了R中的字符串变量,我想随机显示在一个单选按钮上。有20个要素 public void createQuestion() { int

我试图传递我存储在android应用程序数组中的变量,以便它们可以显示在屏幕上,并且我一直收到空指针异常 这就是我一直犯的错误

ViewRoot.handleMessage(Message) line: 1704  
ViewRoot(Handler).dispatchMessage(Message) line: 99
这是传递一个整数数组的代码,它引用了R中的字符串变量,我想随机显示在一个单选按钮上。有20个要素

public void createQuestion()
{
    int temp =(int)Math.floor(Math.random()*20);
    RB1.setText(plantN[temp]);\\this is where the nullpointer is originating
}
类似地,我尝试做同样的事情,但将一个可绘制的数组传递给imageview,我收到了相同的错误
如果您有任何建议,我们将不胜感激。

因此,
RB1
为空,或者
plantN[temp]
为空。甚至是植物本身。 尝试调试空的对象,只需让它记录某个对象是否为空,然后从那里开始