只需要知道访问在不同类中创建的数组的正确语法。
public class item_fragment extends Fragment {
ArrayList<MyItems> mylist;
@Override
public View onCreateView( LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
mylist = ((MyApplication) getActivity().getApplication()).getItemsArrayList();
return inflater.inflate(R.layout.course_work_item_fragment,container, false);
}//ends onCreate View
}
最佳答案
这包括
One thing if you read your code carefully, you have declared ArrayAdapter in Monday_fragment, so this list initialize every time when you replace this fragment with other. So just create a ArrayAdapter in MainActivity and getter, setter for the same and change your methode ArrayList toStringList(Collection entryLogs) in the Monday_fragment like below
关于android - 这是从 fragment 访问数组列表的正确方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36636852/