小编jos*_*das的帖子

什么工具:片段xml文件中的布局?

我使用ADT Eclipse基于主/详细流模板启动了一个新的Android应用程序.此模板创建两个活动,主片段和细节片段,以适应较小和较大的屏幕.

我注意到该activity_item_list.xml文件具有以下tools:layout属性:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/item_list"
    android:name="com.example.fragmenttwopanel.ItemListFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    tools:context=".ItemListActivity"
    tools:layout="@android:layout/list_content" />
Run Code Online (Sandbox Code Playgroud)

我试图删除属性,应用程序以相同的方式运行,但在ADT的图形布局选项卡中,一条消息要求我:

从"片段布局"上下文菜单中选择预览布局

它的目的是什么?它只是用于图形布局的预览吗?

xml android android-layout graphical-layout-editor

25
推荐指数
2
解决办法
2万
查看次数

Android:检查是否使用融合位置提供程序启用了位置服务

根据Android文档:

Google位置服务API是Google Play服务的一部分,它提供了一个功能更强大的高级框架,可自动处理位置提供程序,用户移动和位置准确性,而不是平台位置API android.location.

但是使用融合位置提供程序(来自Google Play服务中的位置API)我不知道如何检查用户是否启用了位置或禁用了位置.

使用旧的 android.location很容易:

locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
Run Code Online (Sandbox Code Playgroud)

但我不想同时使用Google Play服务融合位置提供商和旧的 Android位置.

如何检查用户是否使用融合位置提供程序启用了该位置?

提前致谢.

android location android-location google-play-services fusedlocationproviderapi

18
推荐指数
3
解决办法
3万
查看次数

Android Google Maps v2:点击监听器没有响应

我正在尝试在用户点击地图时添加标记.我正在使用SupportMapFragment内部ActionBarActivity.但是地图没有响应,此外,map.setMapType()操作无效.

这是我的代码:

private GoogleMap map;
private Marker marker;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    ActionBarActivity activity = (ActionBarActivity) getActivity();
    activity.getSupportActionBar().setTitle(R.string.select_location);
    super.onCreateView(inflater, container, savedInstanceState);
    return inflater.inflate(R.layout.map, container, false);
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    Log.d("Map","On view created");
    map = getMap();
            map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
    map.setOnMapClickListener(new OnMapClickListener() {

        @Override
        public void onMapClick(LatLng point) {
            Log.d("Map","Map clicked");
            marker.remove();
            drawMarker(point);
        }
    });

         ...
         Location location = locationManager.getLastKnownLocation(provider);

        if(location!=null){
           //PLACE THE INITIAL MARKER …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-maps-android-api-2

7
推荐指数
1
解决办法
2万
查看次数