due to some limitations in my framework, i need to implement an android app without using xml layouts, i need to do it using java code only.
Also i need to implement this map in a simple Activity, i mean my activity must extend Activity, and not other kind of extended activity. This is also due some limitations in my framework.
I searched in google and stackoverflow and i just find only some answers and code example of how to do it extending FragmentActivity and MapActivity, or using xml layouts like here: https://developers.google.com/maps/documentation/android/start?hl=es
The perfect way for my needs will be to do the same you can read in the official documentation linked above, but without the XML file, using just java code. This is the code showed in the link above:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
I mean i need to transform this into java code:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
0 comments:
Post a Comment