无法访问我在另一个Fragment类中创建的arraylist。基本上我通过意图传递索引,我知道这是有效的,因为我将该值输出到屏幕用于测试目的。但现在我想使用该索引号来访问我在Application类中创建的arraylist。
public class item_fragment extends Fragment {
ArrayList<myItems> myApplication;
@Override
public View onCreateView( LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
myApplication = ((MyFirstApplication) getActivity().getApplication()).getItemsArrayList();
return inflater.inflate(R.layout.item_fragment,container, false);
}//ends onCreate View
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
EditText item = (EditText) view.findViewById(R.id.editText);
Intent myIndex = getActivity().getIntent();
int myValue = myIndex.getIntExtra("Item", 0);
myItems Item = new myItems();
Item = myApplication.get(myValue);
item.setText(Item.toString());
}//ends onViewCreated
}//ends Fragment Class