问题列表 - 第43781页

F3的Eclipse逆转 - Alt-Left并不总是有效

我喜欢Eclipse的按F3(或Ctrl+点击)跳转到声明的功能,但我也想要一个键盘快捷键返回.Alt+ 并不总是这样做(它有时跳到我正在访问的类中的其他行,但有时它确实有效,但仍然没有找到一个模式)并且Ctrl+ Q没有用,因为我没有总是有东西编辑.

eclipse keyboard-shortcuts

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

HTML + CSS:'a'宽度不起作用

我有以下代码:

CSS部分:

<style type="text/css">
    .menu
    {
        width:200px;
    }

    .menu ul
    {
        list-style-image:none;
        list-style-type:none;
    }

    .menu li
    {
        margin:2px;
    }

    .menu A
    {
        height:25px;
        width:170px;
        background:url(./images/button-51.png);
        padding:2px 5px ;
    }

    .menu A:link
    {
        height:25px;
        width:170px;
        background:url(./images/button-51.png);
        padding:2px 5px ;
    }
</style>
Run Code Online (Sandbox Code Playgroud)

HTML部分:

一切正常,但是当我在HTML文档的开头添加'DOCTYPE'元素时:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Run Code Online (Sandbox Code Playgroud)

不考虑'a'元素的宽度.

问题1:为什么?

问题2:如何解决这个问题?

非常感谢!

html css doctype

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

当类的任何属性发生更改时,调用setter

鉴于以下类:

public class LoginInfo
{
    public int UserId;
    public string Username;
}
Run Code Online (Sandbox Code Playgroud)

和另一堂课

public class OtherClass
{
    public static LoginInfo Info
    {
        get
        {
            return SessionBll.GetLoginInfo(someInt);
        }
        set
        {
            SessionBll.UpdateLoginInfo(value, someInt);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

鉴于此:

OtherClass.LoginInfo.Username = "BillyBob";
Run Code Online (Sandbox Code Playgroud)

LoginInfoLoginInfo变更属性时,如何调用setter ?我知道我能做到:

LoginInfo info = OtherClass.LoginInfo;
info.Username = "BillyBob";
OtherClass.LoginInfo = info;
Run Code Online (Sandbox Code Playgroud)

但我想在没有这三行的情况下这样做.我希望它是自动的

谢谢

结束订阅LoginInfo类中的事件

.net c# .net-4.0

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

如何访问BroadcastReceiver中的TextView元素

我在android中测试一个简单的小部件,并使用Alarms定期更新TextView.问题是在BroadcastReceiver类中我无法访问TextView元素,我想在警报到期时更新它.正在调用该类是正确的,因为我已经把Toast放在那里给出了相应的消息.以下代码来自我配置窗口小部件和设置计时器的类.

 public void onCreate(Bundle bundle) {
     super.onCreate(bundle);

     Intent intent = getIntent();
     Bundle extras = intent.getExtras();
     if(extras != null){
      mWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(WidgetConfigure.this);
      RemoteViews views = new RemoteViews(WidgetConfigure.this.getPackageName(), R.layout.widget_layout);
      views.setTextViewText(R.id.quote, "Widget Loaded From Activity");
      appWidgetManager.updateAppWidget(mWidgetId, views);

      setTimer(); //set the timers...
      setResult();// set the result...
     }
 }
Run Code Online (Sandbox Code Playgroud)

现在我想在计时器到期后调用BroadCastReceiver时更新相同的TextView.我已经尝试了android api演示中提供的ExampleAppWidget示例中提供的代码,但是没有用.我该如何设置所需的文字?

layout android widget

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

控制器中的Grails资源路径

假设我将图像URL列表从服务器传递到前端.

images/
    image1.jpg
    image2.jpg
    image3.jpg
Run Code Online (Sandbox Code Playgroud)

现在我只列出文件名,但我需要引用绝对路径(/application/images/image1.jpg).基本上相当于${resource}服务器端.

grails resources controller image

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

为什么我们需要估计卡尔曼滤波器的真实位置?

我正在关注一个关于卡尔曼滤波器的知名教程.

从这些代码行:

figure;
plot(t,pos, t,posmeas, t,poshat);
grid;
xlabel('Time (sec)');
ylabel('Position (feet)');
title('Figure 1 - Vehicle Position (True, Measured, and Estimated)')
Run Code Online (Sandbox Code Playgroud)

我明白那x是真实的位置,y是衡量位置,xhat是估计位置.那么,如果我们可以计算x(这段代码:) x = a * x + b * u + ProcessNoise;,为什么我们需要再估算x一下呢?

math filter kalman-filter

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

领导者选举算法

我正在探索集群计算中的各种架构.一些流行的是:

  1. 主从.
  2. RPC
  3. ...

在Master-slave中,通常的方法是将一台机器设置为主机,将一堆机器设置为主机控制的从机.一个特别的算法让我感兴趣.它被称为Leader-Election Algo,它在选择哪些机器将成为主机时具有一定的随机性.

我的问题是 - 为什么有人想以这种方式选择一台主机?与手动选择机器作为主机相比,这种方法有什么优势?

algorithm distributed-computing cluster-computing master-slave

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

如何将一个变量从javascript函数返回到html体

我仍然是javascript的新手,我正在尝试使用html和javascript返回一个变量的函数.基本上该功能应该只返回用户点击的任何单选按钮,尽管目前我根本没有看到任何返回.

功能在这里:

<script type="text/javascript">
function GetSelectedItem() {
var chosen = ""
len = document.f1.r1.length
  for (i = 0; i <len; i++) {
    if (document.f1.r1[i].checked) {
chosen = document.f1.r1[i].value
    }
  }
}
return chosen
</script>
Run Code Online (Sandbox Code Playgroud)

然后在html部分我有这些单选按钮,我尝试将变量"选择"输出到屏幕.

  <form name = f1><Input type = radio Name = r1 Value = "ON" onClick=GetSelectedItem()>On
  <Input type = radio Name = r1 Value = "OFF" onClick =GetSelectedItem()>Off</form>
  <script type ="text/javascript">document.write(chosen)</script>
Run Code Online (Sandbox Code Playgroud)

目前似乎没有从函数返回任何东西(尽管如果我在函数内输出变量'selected',那么它正在正常工作.

提前致谢!

html javascript

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

BD#for C#NUnit

我一直在使用家庭酿造的BDD Spec扩展来在NUnit中编写BDD样式测试,我想看看每个人都在想什么.它增加了价值吗?真是太糟糕了?如果是这样的话?那里有更好的东西吗?

这是源:https: //github.com/mjezzi/NSpec

我创建这个有两个原因

  1. 使我的测试易于阅读.
  2. 生成普通英语输出以查看规范.

以下是测试外观的示例:

- 这些天僵尸似乎很受欢迎..

鉴于Zombie,Peson和IWeapon:

namespace Project.Tests.PersonVsZombie
{
    public class Zombie
    {

    }

    public interface IWeapon
    {
        void UseAgainst( Zombie zombie );
    }

    public class Person
    {
        private IWeapon _weapon;

        public bool IsStillAlive { get; set; }

        public Person( IWeapon weapon )
        {
            IsStillAlive = true;
            _weapon = weapon;
        }

        public void Attack( Zombie zombie )
        {
            if( _weapon != null )
                _weapon.UseAgainst( zombie );
            else
                IsStillAlive = false;
        }
    }
} …
Run Code Online (Sandbox Code Playgroud)

c# bdd nunit

10
推荐指数
2
解决办法
9088
查看次数

WCF数据服务(OData),具有继承限制的查询?

项目:使用内部EF4 CTP5代码优先方法的WCF数据服务.

我配置了具有继承(TPH)的实体.查看有关此主题的上一个问题:

以前关于多个实体的问题 - 同一个表

映射效果很好,EF4上的单元测试确认查询运行顺利.

我的实体看起来像这样:

  • ContactBase(摘要)
  • Customer(继承自ContactBase),此实体还具有针对其他实体的多个Navigation属性
  • 资源(继承自ContactBase)

我已配置了一个鉴别器,因此Customer和Resource都映射到同一个表.同样,在Ef4的观点上,每个事情都可以正常工作(单元测试所有绿色!)

但是,当通过WCF数据服务公开这个DBContext时,我得到: - CustomerBases设置暴露(客户和资源集似乎是隐藏的,是设计吗?) - 当我在客户上查询Odata时,我收到此错误:

Navigation Properties are not supported on derived entity types. Entity Set 'ContactBases' has a instance of type 'CodeFirstNamespace.Customer', which is an derived entity type and has navigation properties. Please remove all the navigation properties from type 'CodeFirstNamespace.Customer'. 
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

at System.Data.Services.Serializers.SyndicationSerializer.WriteObjectProperties(IExpandedResult expanded, Object customObject, ResourceType resourceType, Uri absoluteUri, String relativeUri, SyndicationItem item, DictionaryContent content, EpmSourcePathSegment currentSourceRoot)
at System.Data.Services.Serializers.SyndicationSerializer.WriteEntryElement(IExpandedResult expanded, Object element, ResourceType expectedType, Uri …
Run Code Online (Sandbox Code Playgroud)

inheritance entity-framework entity-framework-4 wcf-data-services odata

6
推荐指数
1
解决办法
2511
查看次数