【发布时间】:2011-04-14 22:51:01
【问题描述】:
我是一个非常绿色的 android 开发人员,需要一些帮助来解决一个奇怪的程序崩溃问题。通常程序会运行得很好。它失败的可能性相同(见最后的堆栈)。我可以看到程序通过 getView 函数运行,一切似乎都井井有条(即所有信息都按预期存在,并且通过 convertView 看起来很好)。要么它会经历几次,然后程序将是 A-OK,要么它会失败,如下所示,我无法找出导致崩溃的原因。更奇怪的是,如果我以横向模式握住手机,它永远不会失败!它在纵向方向上只有大约 50% 的时间失败。有人可以帮帮我吗?
@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).onLayout(boolean, int, int, int, int) 行:1224 ListView(View).layout(int, int, int, int) 行:6886 LinearLayout.setChildFrame(View, int, int, int, int) 行:1119 LinearLayout.layoutVertical() 行:998 LinearLayout.onLayout(boolean, int, int, int, int) 行:918 LinearLayout(View).layout(int, int, int, int) 行:6886 FrameLayout.onLayout(boolean, int, int, int, int) 行:333 FrameLayout(View).layout(int, int, int, int) 行:6886 LinearLayout.setChildFrame(View, int, int, int, int) 行:1119 LinearLayout.layoutVertical() 行:998 LinearLayout.onLayout(boolean, int, int, int, int) 行:918 LinearLayout(View).layout(int, int, int, int) 行:6886 PhoneWindow$DecorView(FrameLayout).onLayout(boolean, int, int, int, int) 行:333 PhoneWindow$DecorView(View).layout(int, int, int, int) 行:6886 ViewRoot.performTraversals() 行:996 ViewRoot.handleMessage(Message) 行:1633 ViewRoot(Handler).dispatchMessage(Message) 行:99 Looper.loop() 行:123 ActivityThread.main(String[]) 行:4363 Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) 行:不可用 [本机方法] Method.invoke(Object, Object...) 行:521 ZygoteInit$MethodAndArgsCaller.run() 行:862 ZygoteInit.main(String[]) 行:620 NativeStart.main(String[]) 行:不可用 [本机方法]
【问题讨论】:
标签: android exception listview