I have code that should populate my ListView in my UrlListFragment, but when I run it I see no effect. I put the problem aside to work on my WebView, and found that once I load a URL it uses the entire screen. I'm not sure if this means my ListView isn't being populated, so it doesn't take up space, so the WebView takes up the entire screen, or if the WebView is taking up the entire screen regardless of whether the ListView is being populated or not.
I populate my ListView like this:
View returnView = inflator.inflate(R.layout.url_fragment, container, false);
ListView listView1 = (ListView) returnView.findViewById(R.id.mylist);
String[] items = { "http://mobile.cs.fsu.edu/android", "http://www.google.com", "http://my-favoriate-website.com" };
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, items);
listView1.setAdapter(adapter);
return returnView;
And my main XML is this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
I place the Fragments in the main layout programattically like this:
FragmentManager manager = getFragmentManager();
FragmentTransaction trans = manager.beginTransaction();
UrlListFragment urlfragment = new UrlListFragment();
MyWebFragment webfragment = new MyWebFragment();
trans.add(R.id.fragment_container, urlfragment, "my_url_fragment");
trans.add(R.id.fragment_container, webfragment, "my_web_fragment");
trans.commit();
What could the problem be such that my ListView just doesn't appear and my WebView takes up the entire screen?