在活动中编写代码扩展Fragment?

时间:2017-07-15 07:08:00

标签: android listview android-tablayout custom-lists

enter image description here enter image description here任何人都可以告诉我在哪里编写listView代码,以便活动扩展片段会读取它。有onCreateView,因为我映射{ {1}}但仍未阅读。 正如您所看到的,我评论的方法很少,因为它没有阅读它。请告诉我在哪里编写代码来获取输出。以下是我的代码。

listview

2 个答案:

答案 0 :(得分:0)

试试这种方式

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view= inflater.inflate(R.layout.activity_tab1, container, false);

    final ArrayList<PendingPickupBEAN> listPending = (ArrayList<PendingPickupBEAN>)getActivity().getIntent().getSerializableExtra("ARRAYLIST");
   // Log.e(TAG,"Pending piclup list : listbeanobj " + DashboardActivity.listBeanobj.size());


    listview=(ListView) view.findViewById(R.id.listTab1);
    customListView = new CustomListView(getActivity(),R.layout.list_item,DashboardActivity.listBeanobj);

    Log.e(TAG,"=======CUSTOM LIST VIEW ========");
    listview.setAdapter(customListView);

    return  view;

}

答案 1 :(得分:0)

我认为你最后按照上面的回复

   @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

   // final ArrayList<PendingPickupBEAN> listPending = (ArrayList<PendingPickupBEAN>) getIntent().getSerializableExtra("ARRAYLIST");

  Log.e(TAG,"Pending piclup list : listbeanobj " + DashboardActivity.listBeanobj.size());

    View view= inflater.inflate(R.layout.activity_tab1, container, false);


    listview=(ListView) view.findViewById(R.id.listTab1);
    customListView = new CustomListView(getContext(),R.layout.list_item,DashboardActivity.listBeanobj);

    Log.e(TAG,"=======CUSTOM LIST VIEW ========");
    listview.setAdapter(customListView);

    return  view; //here 

    }