ArrayAdapterをFragment内で使いたい
java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
// In the onCreate method AutoCompleteTextView textView = (AutoCompleteTextView) rootView.findViewById(R.id.task_textview); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(), R.layout.fragment_main, COUNTRIES); textView.setAdapter(adapter);
fragment_main.xmlレイアウトファイルにLinearLayoutが入ってその中に、AutoCompleteTextViewが定義されているから問題みたいで、AutoCompleteTextViewだけ切り出せばいいようです。
切り出し方法がわからないなぁ。調べよう。
こちらが正解
Adapterには、android.R.layout_simple_list_item_1というものを指定すればいいようだ。
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(), android.R.layout.simple_list_item_1, COUNTRIES);
intentでカレンダーを再編集できない
新規登録はできるのですが、再編集するのですが、
完了ボタンを押しても値が反映されないのです。
Uri uri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, mLastEventId); long currentTimeMillis = System.currentTimeMillis(); Intent intent = new Intent(Intent.ACTION_EDIT) .setData(uri) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, mStartTimeMills) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, currentTimeMillis); startActivity(intent);
参った。
実機でダメだったらあきらめるか
作成した Android アプリを実機にインストール | アプリ開発覚書
結局、実機のGoogle Calendar,Asus Calendar,CalどれもNGでした。
なんでやろ。
AndroidイベントIDの有無を問い合わせるためコンテンツプロバイダの使い方を学ぼう
カレンダーアプリを作っていて、ごにょごにょしている。
簡単のようで難しい。
直近編集したイベントIDをファイルに保存しておく
- 追加したイベントID一つをファイルに保存。
- カレンダーから編集したイベントを削除
- アプリの編集ボタンを押下
- ファイルからイベントIDを読み込み、それが削除されているイベントかどうか問い合わせる(*)
ここの問い合わせでコンテンツプロバイダを利用したクエリを発行したい。
さぁどうする?というところでつまずいております。(はい)
ムムム、基本を読むとなんとなくわかりそうな気がしてきた。
developer.android.com
Androidファイルの保存
AndroidでカレンダーのイベントIDを保存するようにしよう。
Android EmulatorでGoogle CalendarをIntent表示すると「No Calendars」
これと同じ現象だけど。