java - Instantiating Map Fragment in another activity which does not extends FragmentActivty -


i have activity named markattendance has fragment , 2 button's, have created separate mapactivity class extends fragmentactivty. want instantiate mapactivity markattendance.

markattendance

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_mark_attendance);      punchin = (button) findviewbyid(r.id.punchin);     punchout = (button) findviewbyid(r.id.punchout);      tv = (textview) findviewbyid(r.id.tv);      supportmapfragment supportmapfragment = (supportmapfragment)      getsupportfragmentmanager().findfragmentbyid(r.id.map1);     fragmenttransaction fragmenttransaction      =getsupportfragmentmanager().begintransaction();     fragmenttransaction.add(r.id.map1, supportmapfragment,"fragment");     fragmenttransaction.commit();  } 

mapactivty

public class mapsactivity extends fragmentactivity implements  onmapreadycallback {  private googlemap mmap;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_mark_attendance);      supportmapfragment mapfragment = (supportmapfragment)  getsupportfragmentmanager()             .findfragmentbyid(r.id.map1);     mapfragment.getmapasync(this); } @override public void onmapready(googlemap googlemap) {     mmap = googlemap;      latlng sydney = new latlng(-34, 151);     mmap.addmarker(new markeroptions().position(sydney).title("marker in  sydney"));     mmap.movecamera(cameraupdatefactory.newlatlng(sydney));  } } 

markattendance.xml

<framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/framelayout" android:background="@color/cyan">  <android.support.v7.widget.appcompatbutton     android:id="@+id/punchout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:layout_gravity="center_horizontal"     android:layout_marginbottom="50dp"     android:layout_marginstart="90dp"     android:layout_marginend="90dp"     android:text="@string/punchout"     android:textcolor="@color/white"     android:drawablestart="@drawable/ic_punch"     android:background="@drawable/punchout_button"     style="@style/base.widget.appcompat.button.borderless"/>      <fragment xmlns:android="http://schemas.android.com/apk/res/android"         xmlns:tools="http://schemas.android.com/tools"         android:id="@+id/map1"         android:name="com.google.android.gms.maps.supportmapfragment"         android:layout_width="match_parent"         android:layout_height="250dp"  tools:context="com.example.administrator.employeeattendance.mapsactivity"/>  </framelayout> 

should id of mapactivity should pointing xml of markattendance? what trying create similar this.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -