小编Fra*_*iee的帖子

VS2010单元测试"待定"且测试无法完成

我正在使用VS2010(使用Windows 7).

每次我尝试运行单元测试时,它都会保持"待定"状态,并且测试无法完成.

我试着遵循这个msdn说明.

我尝试调试测试方法(测试视图/调试选择),设置断点,但VS2010指示:断点当前不会被命中...我正在调试配置.

有什么建议?

unit-testing visual-studio-2010

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

找不到PreferenceScreen类

我有一个简单的preferences.xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <PreferenceCategory
                android:title="First Category">
                <CheckBoxPreference
....
Run Code Online (Sandbox Code Playgroud)

我的android版本是2.1(API7)java是1.6,使用eclipse indigo.在包浏览器中有android.jar,在我打开它之后有android.preference包.

即便如此,我收到以下错误:

com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- PreferenceCategory (Fix Build Path, Edit XML)
- PreferenceScreen (Fix Build Path, Edit XML)
Run Code Online (Sandbox Code Playgroud)

我该怎么办?Thanx提前

java android

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

为什么onDraw()不断调用?

我有一个小应用程序,它使用自定义的LinearLayout,称为LinearlayoutOutlined.我想在其中绘制不同大小和彩色的盒子.它还有两个指示时间间隔的文本标签.在进行一些用户操作后,必须重新绘制布局.因此我按原样刷新布局

slotPanel.setDayBoundariesInMinutes( db, dw );
TimeSlot[] tSlots = nextDaysSlots.getGaps( dayOfWeek );
slotPanel.setItems( tSlots );
slotPanel.invalidate();  
Run Code Online (Sandbox Code Playgroud)

其中slotpanelLinearLayoutOutlined实例.

我检测到onDraw方法被不断调用.在特定的循环次数之后,它不会停止调用.

这是整个LinearLayoutOutlined类:

包com.widgets;

public class LinearLayoutOutlined extends LinearLayout {
    private int workingTimeBeginsInMinutes;
    private int workingTimeFinishesInMinutes;
    private TimeSlot[] items;
    private Rect outline;
    private Paint strokePaint = new Paint();
    SimpleDateFormat formatter;
    public LinearLayoutOutlined( Context context ) {
        super( context );
        setWillNotDraw( false );
    }
    public LinearLayoutOutlined( Context context, AttributeSet attrs ) {
        super( context, attrs );
        setWillNotDraw( false );
    }
    public void …
Run Code Online (Sandbox Code Playgroud)

android android-linearlayout

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

LINQ右连接和左连接

我的任务是将一些t-sql查询重构为LINQ.简单连接和左外连接都很清楚.这是我的代码:

string[] leftouter = new string[] { "a", "b", "c", "d", "e" };
string[] inner     = new string[] { "a", "b" };

var q = from s1 in leftouter
        join s2 in inner on s1 equals s2 into j
        from sj in j.DefaultIfEmpty() 
        select string.Format("Outer: {0} Left: {1}", s1, sj)
Run Code Online (Sandbox Code Playgroud)

输出是:

Outer: a Left: a  
Outer: b Left: b  
Outer: c Left:   
Outer: d Left:   
Outer: e Left:   
Run Code Online (Sandbox Code Playgroud)

这是一个简单的左连接.现在我想添加一个新的数据集:

string[] rightouter = new string[] { "c", "d", "e" };  
Run Code Online (Sandbox Code Playgroud)

所需的输出是: …

c# linq

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

序列化没有引号的int类型

我有以下类来序列化:

[Serializable]
public class LabelRectangle { 
  [XmlAttribute]
  public int X { get; set; }
  [XmlAttribute]
  public int Y { get; set; }
  [XmlAttribute]
  public int Width { get; set; }
  [XmlAttribute]
  public int Height { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

它将被序列化,看起来像这样

<LabelRectangle X="15" Y="70" Width="10" Height="1" />
Run Code Online (Sandbox Code Playgroud)

但我想得到以下结果:

<LabelRectangle X=15 Y=70 Width=10 Height=1 />
Run Code Online (Sandbox Code Playgroud)

这是序列化没有引号的int类型值.有可能吗?如果是的话?

.net c#

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

在集合的末尾添加一个新行

我想使用未排序的泛型集合来存储值.

Set<Integer> map = new HashSet<Integer>();
map.Add( new Integer( 3 ) );
map.Add( new Integer( 2 ) );
map.Add( new Integer( 4 ) );
map.Add( new Integer( 1 ) );
Run Code Online (Sandbox Code Playgroud)

我想这些元素将是3,2,4,1.然后我想从这个集合创建一个数组:

Integer[] arr = ( Integer[] )map.toArray( new Integer[map.size()] );
Run Code Online (Sandbox Code Playgroud)

而且我很惊讶,因为arr中的元素与我放入地图的顺序不同.这笔交易是得到这样的数组:

arr[0] = 3;
arr[1] = 2;
arr[2] = 4;
arr[3] = 1;
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

java sorting generics hashset

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