I use the viewpager to scroll between two tabs in the action bar (using the eclipse wizard for this kind of navigation). I am using android maps v2 api.
I want to have mapview, button and textview inside one of my tabs (I assume that map display is not possible).
I inflate the layout for my snippet from xml as follows:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.first_tab_fragment, container, false); } }
My first_tab_fragment.xml:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <com.google.android.gms.maps.MapView android:id="@+id/mapview" android:layout_width="100dip" android:layout_height="100dip" android:layout_alignParentTop="true" android:layout_alignRight="@+id/textView1" android:layout_marginRight="15dp" > </com.google.android.gms.maps.MapView> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/textView1" android:layout_centerHorizontal="true" android:text="Button" /> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignRight="@+id/button1" android:layout_marginBottom="133dp" android:text="TextView" />
MapView is not displayed, just a text box and a button. I also have no errors. Do I need to write code to initialize mapview?
java android android-fragments android-viewpager android-maps-v2
Dixie flatline
source share