Я очень зеленый разработчик для Android и мне нужна помощь в странном сбое программы. Часто программа будет работать просто отлично. Существует равная вероятность того, что он потерпит неудачу (см. Стек в конце). Я могу наблюдать за запуском программы через функцию getView, и все кажется в порядке (т.е. вся информация там, как и ожидалось, и проходит через convertView, казалось бы, нормально). Либо она будет проходить несколько раз, а затем программа будет работать нормально, либо произойдет сбой, как показано ниже, и я не смог определить причины сбоя. Еще более странно, что если я буду держать телефон в ландшафтном режиме, он никогда не выйдет из строя! Не удается только около 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;
}
}
----------------------- ----------------------- Failure -----------------------
Поток [<3> main] (Приостановлено (исключение ArrayIndexOutOfBoundsException))
Строка ListView.layoutChildren (): 1686
ListView (AbsListView) .onLayout (логическое, 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 (логическое, int, int, int, int) строка: 918
LinearLayout (View) .layout (int, int, int, int) строка: 6886
FrameLayout.onLayout (логическое, 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 (логическое, int, int, int, int) строка: 918
LinearLayout (View) .layout (int, int, int, int) строка: 6886
PhoneWindow $ DecorView (FrameLayout) .onLayout (логическое, int, int, int, int) строка: 333
PhoneWindow $ DecorView (View) .layout (int, int, int, int) строка: 6886
ViewRoot.performTraversals () строка: 996
ViewRoot.handleMessage (Сообщение) строка: 1633
ViewRoot (Обработчик) .dispatchMessage (Сообщение) строка: 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 []) строка: недоступно [собственный метод]