【发布时间】:2016-03-22 23:48:55
【问题描述】:
我已经编写了代码以在我的一个片段(选项卡)中包含谷歌地图,我似乎遇到了地图读取回调的问题,它说它未使用的导入语句。我所有的库都已编译,我已经同步了 gradle,但它仍然无法工作,我还是 android 新手,所以这不是我最擅长的领域。
下面是我的代码
package com.example.hp_user.shoutfinal28;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
public class FragmentShouts_Maps extends Fragment implements onMapReadyCallback { View view = inflater.inflate(R.layout.fragmentshouts_maps, container, false);
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Get the view from fragment shouts.xml
return inflater.inflate(R.layout.fragmentshouts_maps, container, false);
MapFragment fragment = (MapFragment)getChildFragmentManager().findFragmentById(R.id.maps);
fragment.getMapAsync(this);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Override
public void onMapReady (GoogleMap googleMap)
}
这是我声明地图的 xml 文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment android:id="@+id/maps"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.example.hp_user.shoutfinal28.FragmentShouts_Maps"
android:layout_alignParentEnd="true">
</fragment>
</RelativeLayout>
【问题讨论】:
标签: android google-maps android-studio