Android ListView.layoutChildren中特定于方向的失败--异常ArrayIndexOutofBoundsException
我是一个非常绿色的android开发者,需要一些帮助来应对一个奇怪的程序崩溃。通常,程序运行得很好。它失败的可能性是相同的(见末尾的堆栈)。我可以通过getView函数看到程序运行,一切看起来都井然有序(即,所有信息都如预期的那样存在,并通过convertView看起来很好)。要么它将经过几次,然后程序将是a-OK,要么它将失败,如下图所示,我无法找出导致崩溃的原因。更奇怪的是,如果我把手机保持在横向模式,它将永远不会失败!!在纵向方向上,它只会失败大约50%。有人能帮我吗Android ListView.layoutChildren中特定于方向的失败--异常ArrayIndexOutofBoundsException,android,exception,listview,Android,Exception,Listview,我是一个非常绿色的android开发者,需要一些帮助来应对一个奇怪的程序崩溃。通常,程序运行得很好。它失败的可能性是相同的(见末尾的堆栈)。我可以通过getView函数看到程序运行,一切看起来都井然有序(即,所有信息都如预期的那样存在,并通过convertView看起来很好)。要么它将经过几次,然后程序将是a-OK,要么它将失败,如下图所示,我无法找出导致崩溃的原因。更奇怪的是,如果我把手机保持在横向模式,它将永远不会失败!!在纵向方向上,它只会失败大约50%。有人能帮我吗 @O
@Override
public View getView(int position, View convertView, ViewGroup parent){
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
ADDPResults addpres = items.get(position);
if (addpres != null) {
//initialize display variables from inflated row.xml variables
TextView iptext = (TextView) v.findViewById(R.id.IPtext);
TextView mactext = (TextView) v.findViewById(R.id.MACtext);
TextView nametext = (TextView) v.findViewById(R.id.Nametext);
TextView devicetext = (TextView) v.findViewById(R.id.Devicetext);
//TextView firmwaretext = (TextView) v.findViewById(R.id.Firmwaretext);
//write the real data to the display
iptext.setText("IP Address: "+addpres.addp_deviceIP.toDecString());
mactext.setText("MAC Address: "+addpres.addp_deviceMAC.toHexString() );
nametext.setText("Name: "+addpres.addp_devName);
devicetext.setText("Device: "+addpres.addp_devType);
//firmwaretext.setText("Firmware: "+addpres.addp_FWVersion);
}
return v;
}
}
-----------------------失败----------------------------------------------
线程[main](挂起(异常ArrayIndexOutOfBoundsException))
ListView.layoutChildren()行:1686
ListView(AbsListView)。仅布局(布尔,int,int,int,int)行:1224
列表视图(视图)。布局(int,int,int,int)行:6886
setChildFrame(视图,int,int,int,int)行:1119
LinearLayout.layoutVertical()行:998
线性布局。仅布局(布尔,int,int,int,int)行:918
线性布局(视图)。布局(int,int,int,int)线:6886
FrameLayout.onLayout(boolean,int,int,int,int)行:333
框架布局(视图)。布局(int,int,int,int)行:6886
setChildFrame(视图,int,int,int,int)行:1119
LinearLayout.layoutVertical()行:998
线性布局。仅布局(布尔,int,int,int,int)行:918
线性布局(视图)。布局(int,int,int,int)线:6886
PhoneWindow$DecorView(FrameLayout).仅限布局(boolean,int,int,int,int)行:333
PhoneWindow$DecorView(视图)。布局(int,int,int,int)行:6886
ViewRoot.performTraversals()行:996
ViewRoot.handleMessage(消息)行:1633
ViewRoot(处理程序)。dispatchMessage(消息)行:99
Looper.loop()行:123
ActivityThread.main(字符串[])行:4363
invokenactive(Object,Object[],Class,Class[],Class,int,boolean)行:不可用[本机方法]
调用(对象,对象…)行:521
ZygoteInit$MethodAndArgsCaller.run()行:862
颧骨单位主(弦[])线:620
NativeStart.main(String[])行:不可用[本机方法]我将检查您得到的“位置”,并将其与您的项目数组的大小进行比较。。。因为异常显示:ArrayIndexOutOfBoundsException我检查了它。通常,数组中有5个项目,“位置”不会像预期的那样超过4个。通常,崩溃会发生在“Position=4”迭代中,但并不总是如此。