Hello. I am a very green android developer and need some help with a strange program crash. Often the program will run just fine. There is an equal chance it will fail (see stack at the end). I can watch the program run through the getView function and everything seems in order (i.e. all the information is there as expected and passes through convertView seemingly fine). Either it will go through a few times and then program will be A-OK or it will fail as seen below and I have not been able to pick out what causes the crash. Even stranger is that if I hold the phone in landscape mode, it will never fail!! It only fails about 50% of the time in portrait orientation. Can someone please help me?
@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---------------------------------------------- Thread [<3> main] (Suspended (exception ArrayIndexOutOfBoundsException)) ListView.layoutChildren() line: 1686 ListView(AbsListView).onLayout(boolean, int, int, int, int) line: 1224 ListView(View).layout(int, int, int, int) line: 6886 LinearLayout.setChildFrame(View, int, int, int, int) line: 1119 LinearLayout.layoutVertical() line: 998 LinearLayout.onLayout(boolean, int, int, int, int) line: 918 LinearLayout(View).layout(int, int, int, int) line: 6886 FrameLayout.onLayout(boolean, int, int, int, int) line: 333 FrameLayout(View).layout(int, int, int, int) line: 6886 LinearLayout.setChildFrame(View, int, int, int, int) line: 1119 LinearLayout.layoutVertical() line: 998 LinearLayout.onLayout(boolean, int, int, int, int) line: 918 LinearLayout(View).layout(int, int, int, int) line: 6886 PhoneWindow$DecorView(FrameLayout).onLayout(boolean, int, int, int, int) line: 333 PhoneWindow$DecorView(View).layout(int, int, int, int) line: 6886 ViewRoot.performTraversals() line: 996 ViewRoot.handleMessage(Message) line: 1633 ViewRoot(Handler).dispatchMessage(Message) line: 99 Looper.loop() line: 123 ActivityThread.main(String[]) line: 4363 Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method] Method.invoke(Object, Object...) line: 521 ZygoteInit$MethodAndArgsCaller.run() line: 862 ZygoteInit.main(String[]) line: 620 NativeStart.main(String[]) line: not available [native method]