小编Nic*_*tch的帖子

如何从本机代码强制打开Android软键盘?

我有一个游戏,它使用C++回调来强制打开软键盘,当用户触摸屏幕时.Java代码就是这样的:

this._inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
Run Code Online (Sandbox Code Playgroud)

这已经好了一段时间,但最近我们收到一些摩托罗拉Droid用户的抱怨,软键盘无法为他们打开.由于我们最近才开始接受这些投诉,而且我认为这是对这些设备进行某种更新.

有没有更好的方法可以强制键盘打开?我在网上找到的所有链接都谈到使用文本框控件等,但我的应用程序主要是C++,根本不使用标准控件.

android android-ndk android-softkeyboard

4
推荐指数
1
解决办法
2948
查看次数

在VB.NET中将变量名存储在String中

我正在尝试将一些变量的名称存储在字符串中.例如:

Dim Foo1 as Integer
Dim Foo1Name as String

' -- Do something to set Foo1Name to the name of the other variable --

MessageBox.Show(Foo1Name & " is the variable you are looking for.")
' Outputs:
' Foo1 is the variable you are looking for.
Run Code Online (Sandbox Code Playgroud)

这将有助于我正在进行的一些调试.

vb.net string variables

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

RIA服务不归还包含类型收集财产

我有一个WCF RIA Services应用程序和一个UserRole类型的模型,其中包含UserPermission对象的集合.我在域服务中使用.Include("UserPermission"),当我调试它时,我确认它在返回之前肯定包含UserPermission类型.

当我调试Silverlight 3客户端时,它返回UserRoles,但UserPermission属性都是空的.这些是显示在服务上具有UserPermissions的UserRoles.

由于服务和客户端上的所有内容都是正确的,我专注于元数据类,但仍然找不到任何错误.

[MetadataTypeAttribute(typeof(UserRole.UserRoleMetadata))]
public partial class UserRole
{
    internal sealed class UserRoleMetadata
    {
        public int RoleID;
        public string Name;

        [Include]
        [Association("UserPermissions", "RoleID", "PermissionID")]
        public EntityCollection<UserPermission> UserPermissions;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是域服务方法:

public IEnumerable<UserRole> GetUserRoles()
{
    IEnumerable<UserRole> roles = this.ObjectContext.UserRole.Include("UserPermissions");
    return roles; // In debug, roles.First().UserPermissions.Count = 2 here
                  // For now, there is only one single role in the ObjectContext and it has
                  // two UserPermissions
}
Run Code Online (Sandbox Code Playgroud)

这是Silverlight客户端方法:

context.Load(context.GetUserRolesQuery(), loadOp =>
{
    IEnumerable<UserRole> roles = loadOp.Entities;
    // This …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework .net-3.5 wcf-ria-services

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

如何在Google App Engine数据存储区中创建参考列表?

Foo我的Google App Engine数据存储区中有一个类型.我希望它链接到一系列其他Foo类型,称之为prerequisites.

我可以使用该ListProperty类型来创建简单值类型的列表,但我不知道如何使用引用来执行此操作.这样做的推荐方法是什么?

google-app-engine google-cloud-datastore

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

匹配正则表达式中的开始/结束对字符

首先,介绍一下背景。我有类似于以下内容的字符串:

((Foo.Bar.StartsWith("A")) && (Foo.Bar.EndsWith("B")))

我正在尝试将这些重新格式化为如下所示:

((Foo.Any(Bar.StartsWith("A"))) && (Foo.Any(Bar.EndsWith("B"))))

旁注: .Bar 后面的部分有时可能不包含 (),例如 .Bar == "AB" 。

我试图捕捉两个群体:Foo。和 Bar.StartsWith("<A or B>") 。我制定了以下模式,但它删除了尾随括号。

\((Foo\.)(.*?)\)
Run Code Online (Sandbox Code Playgroud)

因此,我得到的不是我想要的,而是:

((Foo.Any(Bar.StartsWith("A")) && (Foo.Any(Bar.EndsWith("B")))

这是两个括号短。

问题是我需要在 .* 中包含右括号?如果那里还有一个左括号,则匹配。我还没想好怎么做,有人知道吗?

PS - 代码是 C#.NET 但这应该无关紧要,除非解决方案涉及一些晦涩的语言特定的 RegEx 内容。

regex pattern-matching

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

在C++中传递C-Strings的问题

我不是C++开发人员,我想弄清楚为什么当我从一个函数返回一个C字符串时,我会得到垃圾.

#include <stdio.h>

const char* tinker(const char* foo);

int main(void)
{
    const char* foo = "foo";
    foo= tinker(foo);
    printf(foo); // Prints garbage
    return 0;
}

const char* tinker(const char* foo)
{
    std::string bar(foo);
    printf(bar.c_str());  // Prints correctly
    return bar.c_str();
}
Run Code Online (Sandbox Code Playgroud)

c++ string

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

Android GLSurfaceView.Renderer正在中断不完整的触摸事件

这是我一直遇到的一个问题,我希望这里的某个人能够对此有所了解.

我有一个Android游戏加载一个GLSurfaceView谁的渲染器设置如下:

public class GameRenderer implements GLSurfaceView.Renderer
{
    public void onSurfaceCreated(GL10 gl, EGLConfig config)
    {
        BaseLib.init(); // Initializes the native code
    }

    public void onSurfaceChanged(GL10 gl, int width, int height)
    {}

    public void onDrawFrame(GL10 gl)
    {
        BaseLib.render(); // Call to native method to render/update the current frame
    }
}
Run Code Online (Sandbox Code Playgroud)

视图是这样的:

public class GameView extends GLSurfaceView implements SurfaceHolder.Callback
{
    private GameRenderer _renderer;
    private GameListener _listener;

    public GameView(Context context)
    {
        super(context);
        this._renderer = new GameRenderer();
        setRenderer(this._renderer);
        this._listener = new GameListener();
        BaseLib.setListener(this._listener);
    } …
Run Code Online (Sandbox Code Playgroud)

android android-ndk-r4

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

有没有办法将枚举映射到C#.NET 3.5中的另一个枚举?

我正在尝试设置一个枚举,将某些特定于项目的值映射到标准的System.Drawing.Color枚举.

这是我想做的事情的想法:

public enum SessionColors
{
     Highlights = Color.HotPink,
     Overlays   = Color.LightBlue,
     Redaction  = Color.Black   
}
Run Code Online (Sandbox Code Playgroud)

我的目标是拥有它,所以我可以使用SessionColors.Highlights来识别我认为是一个亮点,然而,我可以稍后更改枚举映射并影响所有后续颜色.

我意识到我可以查看Color.HotPink等的值.并且只是使用它们但它并不那么清楚.还有更好的主意吗?

.net enums c#-3.0

0
推荐指数
1
解决办法
1156
查看次数