问题列表 - 第27365页

如何更改TextView上的字体?

如何更改a中的字体TextView,默认显示为Arial?如何将其更改为Helvetica

fonts android textview

280
推荐指数
11
解决办法
45万
查看次数

std :: string操作:空格,"newline escapes'\'"和注释#

有点在这里寻求肯定.我有一些手工编写的代码,我并不害羞地说我很自豪,它会读取文件,删除前导空格,处理换行符'\'并删除以#开头的注释.它还会删除所有空行(也是仅空白行).有什么想法/建议?我可以用std :: runtime_errors替换一些std :: cout ......但这不是优先考虑的事:)

const int RecipeReader::readRecipe()
{
    ifstream is_recipe(s_buffer.c_str());
    if (!is_recipe)
        cout << "unable to open file" << endl;
    while (getline(is_recipe, s_buffer))
    {
        // whitespace+comment
        removeLeadingWhitespace(s_buffer);
        processComment(s_buffer);
        // newline escapes + append all subsequent lines with '\'
        processNewlineEscapes(s_buffer, is_recipe);
        // store the real text line
        if (!s_buffer.empty())
            v_s_recipe.push_back(s_buffer);
        s_buffer.clear();
    }
    is_recipe.close();
    return 0;
}

void RecipeReader::processNewlineEscapes(string &s_string, ifstream &is_stream)
{
    string s_temp;
    size_t sz_index = s_string.find_first_of("\\");
    while (sz_index <= s_string.length())
    {
        if (getline(is_stream,s_temp))
        {
            removeLeadingWhitespace(s_temp);
            processComment(s_temp);
            s_string …
Run Code Online (Sandbox Code Playgroud)

c++ string algorithm

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

Java:什么是"for(;;)"

请问任何人请为我解释这个说明:for(;;)

我遇到过几种这样的标记(比如在facebook的ajax代码和Java的并发代码中).

java

10
推荐指数
3
解决办法
453
查看次数

Nokogiri vs Hpricot?

你会选哪一个?我的重要属性是(不按顺序):

  1. 支持和未来的增强功能.
  2. 社区和一般知识库(在互联网上).
  3. 全面的(IE,经证明可以解析各种*.*ml页面).
  4. 性能.
  5. 内存占用(运行时,而不是代码库).

ruby hpricot html-parsing nokogiri

23
推荐指数
3
解决办法
7267
查看次数

Postgres 以编程方式打开 log_statement

我想打开修改数据库的所有 SQL 语句的日志记录。我可以通过在配置文件中设置 log_statement 标志来在我自己的计算机上获得该功能,但需要在用户的计算机上启用它。如何从程序代码中启用它?(如果重要的话,我将 Python 与 psycopg2 一起使用。)

postgresql logging psycopg2

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

使用Lift-JSON解析动态值

让我用一个例子来解释这个问题.如果我有如下的JSON:

{"person1":{"name":"Name One","address":{"street":"Some Street","city":"Some City"}},
"person2":{"name":"名称两个","地址":{"street":"Some Other Street","city":"Some Other City"}}}

[对人数没有限制,输入JSON可以有更多人]

我可以通过这样做将这个JSON提取到Persons对象

var persons = parse(res).extract [T]

以下是相关的案例类:

case class Address(street:String,city:String)
case类Person(name:String,address:Address,children:List [Child])
case class Persons(person1:person,person2:Person)

问题:上述情况完全正常.然而,需要的是密钥/值对中的密钥是动态的.所以在提供的示例JSON中,person1person2可以是任何东西,我需要动态地读取它们.人类课程考虑到这种动态性质的最佳结构是什么.

json scala lift

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

autofac的Func <T>来解析命名服务

鉴于注册服务:

builder.RegisterType<Foo1>().Named<IFoo>("one").As<IFoo>();
builder.RegisterType<Foo2>().Named<IFoo>("two").As<IFoo>();
builder.RegisterType<Foo3>().Named<IFoo>("three").As<IFoo>();
Run Code Online (Sandbox Code Playgroud)

我可以IFoo通过注入类似的东西来检索接口的命名实现Func<string, IFoo>吗?

public class SomeClass(Func<string, IFoo> foo) {
    var f = foo("one");
    Debug.Assert(f is Foo1);

    var g = foo("two");
    Debug.Assert(g is Foo2);

    var h = foo("three");
    Debug.Assert(h is Foo3);
}
Run Code Online (Sandbox Code Playgroud)

我知道我可以做到Meta<>,但我不想使用它.

.net c# dependency-injection ioc-container autofac

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

Java术语:为什么编译时错误而不是编译时异常?

这可能听起来很尴尬......
但我不明白.

为什么我们有compile-time error而不是compile-time exception在java?

我的意思是说我们从不说compile-time exception.
我们倾向于说它compile-time error.

是否有任何具体原因?
欢迎任何建议......

谢谢 !

java exception-handling exception

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

StackExchange API的JSON URL返回乱码?

我有一种感觉,我在这里做错了,但我不太确定我是否错过了一步,或者只是遇到了编码问题.这是我的代码:

URL url = new URL("http://api.stackoverflow.com/0.8/questions/2886661");

   BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
   // Question q = new Gson().fromJson(in, Question.class);
   String line;
   StringBuffer content = new StringBuffer();
   while ((line = in.readLine()) != null)
   {
    content.append(line);
   }
Run Code Online (Sandbox Code Playgroud)

当我打印内容时,我得到了一大堆的翅膀和特殊的角色,基本上是乱七八糟的.我会在这里复制并通过它,但这不起作用.我究竟做错了什么?

java url json stackexchange-api

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

在Silverlight 4中托管Microsoft Office应用程序?

我知道Silverlight 4通过AutomationFactory该类支持COM互操作.

dynamic excel = AutomationFactory.CreateObject( "Excel.Application" );
excel.Visible = true;
Run Code Online (Sandbox Code Playgroud)

但是这会为COM对象创建一个单独的窗口.我在这里缺少的是,如果我实际上能够在我的Silverlight应用程序中实际托管Office文档 - 例如在ContentPresenter中?

silverlight com-interop silverlight-4.0

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