I can't seem to get to the bottom of this. Using Apache POI to read excel files. Seem to be hitting errors. Making app force close.
java.lang.IllegalStateException: Could not execute method for android:onClick
My XML android:onClick id has the same name as my method listener:
<Button
android:text="OK"
android:id="@+id/submitOK"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:textSize="12sp"
android:background="@drawable/round_button"
android:gravity="center_vertical|center_horizontal"
android:textColor="#fff"
android:layout_alignTop="@+id/setName"
android:layout_toRightOf="@+id/setName"
android:layout_marginLeft="5dp"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignBottom="@+id/setName"
**android:onClick="inRoster"**
android:visibility="gone"
/>
public void inRoster(View v) throws IOException {
if (checkValidinFile()) {
// Send to a new page that lists your shifts, what time you want your alarms
// and what time you want messages to be sent
// What time do you want to send the messages?
// What time do you want your alarms to be?
// Do all alarm and message sending bs
} else {
// Display a toast message saying name not found
// Clear contents of the editbox for the name for user to re enter
CharSequence text = "Name not found in Roster!";
setName.setText("");
int duration = Toast.LENGTH_SHORT;
Toast.makeText(this, text, duration).show();
}
}
This is seemingly where the errors come up in this method but I can't see why.
public boolean checkValidinFile() throws IOException {
String nameToMatch = setName.getText().toString().toLowerCase();
try {
InputStream ExcelFileToRead = new FileInputStream(roster);
XSSFWorkbook wb = new XSSFWorkbook(ExcelFileToRead);
XSSFSheet sheet = wb.getSheetAt(0);
Iterator<Row> iterator = sheet.iterator();
while (iterator.hasNext()) {
Row currentRow = iterator.next();
Iterator<Cell> cellIterator = currentRow.iterator();
while (cellIterator.hasNext()) {
Cell currentCell = cellIterator.next();
System.out.println(currentCell.toString() + " ");
}
}
System.out.println();
wb.close();
ExcelFileToRead.close();
}
catch (IOException e) {
e.printStackTrace();
}
return true;
}
'SetName' is defined at the top of the class globally without instantiation and then defined in onCreate as:
setName = (EditText) findViewById(R.id.setName);
Any help is appreciated, let me know what other information you need, I'm also getting some other issue with I/art rejecting re-init on previously-failed classes. See link below if you think the two issues may be linked.