【发布时间】:2015-04-27 12:29:49
【问题描述】:
我正在开发一个应用程序,我将代码从 Java 转换为 C#,以在 android 上以离线模式创建自定义 MapView。
我正在使用这个用 Java 编写的 tutorial,并且有一些命名空间我无法理解本教程的创建者甚至从哪里得到它们,尤其是写为 import com.mapapp.mapapp.R; 的特定命名空间。
为了指定我在哪里工作,我正在从事这项活动。
我什至不知道在尝试查找有关它的信息时要搜索什么,因为它被写成好像它是项目中的一个类,但是通过查看package com.mapapp.main;,它似乎应该是一个 nuget 包或在同一解决方案中引用不同的项目。但是创作者在教程中从来没有提到过类似的东西。
package com.mapapp.main;
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Environment;
import android.view.Display;
import android.view.KeyEvent;
import com.mapapp.helpers.PointD;
import com.mapapp.mapapp.R;
import com.mapapp.tileManagement.TilesProvider;
import com.mapapp.views.MapView;
import com.mapapp.views.MapViewLocationListener;
在这种情况下,这个命名空间在 C# 中的等价物是什么,什么是 R?
这是代码中使用 R 的部分:
void initViews()
{
// Creating the bitmap of the marker from the resources
Bitmap marker = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
// Creating our database tilesProvider to pass it to our MapView
String path = Environment.getExternalStorageDirectory() + "/mapapp/world.sqlitedb";
tilesProvider = new TilesProvider(path);
// Creating the mapView and make sure it fills the screen
Display display = getWindowManager().getDefaultDisplay();
mapView = new MapView(this, display.getWidth(), display.getHeight(), tilesProvider, marker);
// If a location was saved while pausing the app then use it.
if (savedGpsLocation != null) mapView.setGpsLocation(savedGpsLocation);
// Update and draw the map view
mapView.refresh();
}
【问题讨论】:
标签: java c# android namespaces