I have a snippet that sends a request to the server and loads json, and then parses it into a listview, since I cannot properly convey to the view. The following is part of my applications, this is my first touch on a listview with a fragment, for some reason I only allow the fragment to be used, so I select ' setAdapter ' instead of ' setListAdapter ' for my adapter
myfragment.java
public class gallery extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
layout.tab_frag2_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:background="#ffffff"> <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingLeft="@dimen/list_padding" android:paddingRight="@dimen/list_padding" android:tag="listf" /> </LinearLayout>
My expectation is using
MyListView = (ListView)myFragmentView.findViewById(R.id.list);
to get my opinion, but it doesnβt work like that ... Now I just want to get my list and apply
MyListView.setAdapter(colorAdapter) to it
any help would be appreciated thanks
source share