私はこのファイルを読み込んで、assetsフォルダ(myファイル名:book.xls)に貼り付けてExcelファイルを読み込みます。しかし、私はボタンを押してファイルを表示すると、それは動作しないし、何も表示されません。 私の問題を解決するのを手伝ってください。 ありがとうございました。 ここに私のコードです:display()
メソッドは決してあなたの内側のfor
ループとしてandroid.javaのExcelファイルを読む
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android.readingexcellfile.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:id="@+id/textView" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="28dp"
android:layout_marginStart="28dp"
android:layout_marginTop="69dp"
android:onClick="order"
android:id="@+id/button" />
</RelativeLayout>
この問題を解決したら、次に考慮すべきことは「なぜExcelファイルなのか」です。 ファイルがassetsフォルダに埋め込まれていて、ユーザーがそのファイルを変更できない場合は、.csvファイルなどのよりフレンドリーな形式に変換するだけでなく、Javaでデータクラスを作成するこのデータは? 次に、ExcelファイルとJexcelライブラリの両方を省略することで、APKをもっと小さくすることができます。 – GreyBeardedGeek