私はこれの最下部にいるようです。 Apache POIを使用してファイルを読み取る誤りを犯すと思われる。アプリを強制的に閉じる。Androidのメソッドonroid:onClickを実行できませんでした
java.lang.IllegalStateException: Could not execute method for android:onClick
マイXMLのアンドロイド:onClickのidは私のメソッドリスナーと同じ名前を持つ:
<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();
}
}
エラーは、この方法で出てくるけどここは一見です理由を見ることができません。
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メソッド」インスタンス化せずに、グローバルクラスの先頭に定義され、その後のonCreateで定義されています。すべてのヘルプは高く評価され
setName = (EditText) findViewById(R.id.setName);
、私はあなたが必要とする他のどのような情報を知らせ、I以前に失敗したクラスの再初期化を拒否するI/Artで他にもいくつかの問題が発生しています。 2つの問題がリンクされていると思われる場合は、下のリンクを参照してください。
私はdownvotedされている唯一の理由は、そのような '簡単な修正'の理由であると仮定します。なぜそうであれば、downvotingとページを離れるのではなく、downvoteしないで、私は他の同様の答えを見て、同様のインスタンスのために私のコードをチェックし、それらの修正を試みたが、何も解決していない。 –