カスタム アダプター (クラス A としましょう) を備えた ExpandableListView があり、setListAdapter(mAdapter)
別のクラス (クラス B)、具体的にはサービスから呼び出す必要があります。
mAdapter = new Refeicao.MyExpandableListAdapter();
setListAdapter(Refeicao.mAdapter);
stackoverflow の同様の質問から、次のようないくつかの解決策を試しました。
-1 そのコードをクラス A の静的メソッドに入れ、B から呼び出す - しかし、非静的メソッド参照「エラー」を取得しました
-2 ビュー listView = getActivity().findViewById(R.id.list); -サービスがアクティビティではないため、機能しないと思います
-3
メソッド setListAdapter(ExpandableListAdapter) は型に対して定義されていません
static ExpandableListView lv;
lv = (ExpandableListView) findViewById(android.R.id.list);
その後
mAdapter = new A.MyExpandableListAdapter();
A.lv.setListAdapter(mAdapter);
メソッド setListAdapter(ExpandableListAdapter) は、タイプ ExpandableListView に対して定義されていません。
とにかく、私の問題を解決する方法はありますか?