今日は、私は次のエラーを受け取った:私のフラグメントのコンストラクタは空ではないので、私は、コンストラクタについての私のListFragment
でいくつかのデータを表示するには、アダプタを提出 どのようにアダプタをバンドルに入れることができますか?
。だから、バンドルにアダプタを保存する関数を書く必要がありますが、どうすればこれを処理できますか?Unable to instantiate fragment: make sure class name exists, is public, and has an empty constructor that is public
public class AllMedicationsFragment extends ListFragment {
MyAdapter myAdapter;
public static final MyFragment newInstance(MyAdapter adapter) {
MyFragment myFragment = new MyFragment();
Bundle bdl = new Bundle(1);
bdl.put??(adapter);
myFragment.setArguments(bdl);
return myFragment;
}
私は、私は別のアクティビティで呼び出さTimePickerFragment
を実施して以来、このエラーが発生します。
? –
私は別のアクティビティのデータでアダプタを埋めるので、 – developKinberg
あなたは間違って不必要にフラグメントの実装とそのアクティビティを結合しています。代わりに、そのアクティビティからデータを戻し、データをアダプタに渡す必要があります。 –