小编ste*_*urt的帖子

Android方向如转向 - 滚动腐败音高?

嗨,大家好,

我正在开发一个项目,其中包括一个用于控制/转向的Android应用程序.

  • 速度:当您向前/向后倾斜手机(音高)时,它会模拟提供气体和破碎.
  • 方向:向左/向右倾斜手机(滚动)时,模拟向左和向右转向.

我已经写了一些似乎工作正常的代码.但是当我仔细观察时,我发现有些价值观很奇怪.

当我向前/向后倾斜手机以处理速度时,它可以完美地运行,我得到了预期的速度和方向值.但是,当我向左/右倾斜手机以处理方向时,它似乎会破坏某些值.当它向左/向右倾斜时,不仅改变方向值(滚动),而且还影响速度值(俯仰).

有关其他信息:

  • Android 2.2编程
  • 设备是Google Nexus One
  • 握住设备的肖像

我用来读取传感器值的最相关代码如下:

public void onSensorChanged(SensorEvent sensorEvent)
{        
    synchronized (this)
    {
        if (sensorEvent.sensor.getType() == Sensor.TYPE_ORIENTATION)
        {
            float azimuth = sensorEvent.values[0]; // azimuth rotation around the z-axis
            float pitch = sensorEvent.values[1];   // pitch rotation around the x-axis
            float roll = sensorEvent.values[2];    // roll rotation around the y-axis

            System.out.println("pitch: " + pitch);
            System.out.println("roll: " + roll);
            System.out.println("--------------------");

            // Convert the sensor values to the actual speed and direction values …
Run Code Online (Sandbox Code Playgroud)

android orientation pitch

5
推荐指数
1
解决办法
1546
查看次数

获取Orchard ContentItem显示URL

当我在View Alternate中时,我知道我可以通过以下方式获取ContentItem的显示URL:

@Url.ItemDisplayUrl(contentItem)

但是当我在控制器上下文(ActionResult)时,我不知道如何获取显示URL.出于站点地图的目的,我需要列出的ContentItems的URL.

我正在使用下面的代码.

public class SiteMapResult : ActionResult
{
    readonly IContentManager _contentManager;
    readonly ITagService _tagService;

    public SiteMapXmlResult(IContentManager contentManager, ITagService tagService)
    {
        _contentManager = contentManager;
        _tagService = tagService;
    }

    public override void ExecuteResult(ControllerContext context)
    {
        context.HttpContext.Response.ContentType = "text/xml";

        string host = context.HttpContext.Request.Url.Host;
        StringBuilder xml = new StringBuilder();
        xml.Append(@"<?xml version=""1.0"" encoding=""UTF-8""?>");
        xml.Append(@"<urlset xmlns=""http://www.sitemaps.org/schemas/sitemap/0.9"">");

        var contentItems = _contentManager.Query(VersionOptions.Latest, GetContentTypeNames().ToArray()).List();
        foreach (var contentItem in contentItems)
        {

            // The display url of contentItem

        }

        ...

    }
}
Run Code Online (Sandbox Code Playgroud)

如何获取ContentItem显示URL?

sitemap url controller routes orchardcms

3
推荐指数
1
解决办法
3142
查看次数

标签 统计

android ×1

controller ×1

orchardcms ×1

orientation ×1

pitch ×1

routes ×1

sitemap ×1

url ×1