Alfred_6 0 Newbie Poster

Hello! I'm trying to display a list of items in a fragment called AgendaList. I am not quite sure what I missed. Here's what I have under AgendaList onCreateView:

   public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment

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

        String[] menuTasks = {"Complete pleading for case #3485736", "New Case: #3452789 Yoel Romero vs. USADA", "New Case: #45367864 T.J. Dillshaw vs. Dominick Cruz"};

       lvlistview = (ListView) view.findViewById(R.id.lv_task);

        ArrayAdapter<String> listviewAdapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, menuTasks);

        lvlistview.setAdapter(listviewAdapter);

        return view;

    }

and here's the corresponding xml file:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" tools:context="com.example.alfred.pao3.AgendaList"
    android:background="@drawable/bg"> <!-- TODO: Update blank fragment layout --> <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/lv_task"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true" /> </FrameLayout>

This is where I declared my listview:

public class AgendaList extends Fragment {

    ListView lvlistview;
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    private OnFragmentInteractionListener mListener;

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.