ListView in fragment

0

Good afternoon, any help on how to use listView in a fragment? I have seen many tutorials but sincerely they are from previous versions and with the latest version of Android Studio I do not run certain syntax, I appreciate any help.

    
asked by FABIAN AGUILAR 11.03.2017 в 17:34
source

1 answer

0

I guess you need to add the following import that is this: import android.support.v4.app.Fragment; Also in the onCreateView you must declare a variable of type View for example

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

View rootView = inflater.inflate(R.layout.fragment_photos, container, false);


ListView lv = (ListView)rootView.findViewById(R.id.lv_contact);

return rootView;

}

I hope I serve you. Greetings

    
answered by 11.03.2017 в 17:42