问题列表 - 第4831页

如何使用XML根据图像大小调整Android组件的大小

我使用XML布局创建器在Android中创建了一个自定义图标栏,使用LinearLayout中的RadioGroup(下面包含XML).RadioGroup中的每个RadioButton都有一个自定义drawable(带有checked和unchecked状态)作为其android:button属性.

线性布局本身在a内,RelativeLayout因此它可以出现在屏幕上的任意位置(在这种情况下为侧边栏).

drawables宽55像素,android:layout\_width所有这些视图的属性是wrap\_content.

当我使该组件可见时,对齐到屏幕的左下角,只有大约四分之三的RadioButton图像宽度可见.设置layout\_widthRelativeLayout,以fill\_parent 整流这一点,并导致全按钮出现.

但是,这意味着按钮组会在整个屏幕宽度上消耗点击事件.

如何显示整个按钮,并且只有按钮区域响应点击?硬编码可拉伸的宽度不是特别理想的解决方案.

<RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_below="@+id/LinearLayout01" android:visibility="invisible">
        <RadioGroup android:id="@+id/RadioGroup01" android:layout_height="wrap_content" android:checkedButton="@+id/RB01" android:layout_width="fill_parent">
            <RadioButton android:id="@+id/RB01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR01"/>
            <RadioButton android:id="@+id/RB02" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR02"/>
            <RadioButton android:id="@+id/RB03" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR03"/>
            <RadioButton android:id="@+id/RB04" android:layout_width="fill_parent" android:layout_height="wrap_content" android:button="@drawable/DR04"/>
        </RadioGroup>
    </LinearLayout>
    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

xml layout android

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

JProgressBar的替代品?

对于长时间运行的进程,我想要一个很好的进度条.JProgressBar有没有替代品,特别是对于不确定的流程?

我在考虑看起来像Web-2.0的旋转轮,旋转轮,你有什么.

虚构的奖励积分,免费,LGPL许可的东西.;)

java user-interface jprogressbar

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

如何使用XmlSerializer反序列化为现有实例?

是否有可能使用XmlSerializer将其数据反序列化为现有的类实例而不是新的实例?

这在两种情况下会有所帮助:

  1. 轻松将两个XML文件合并到一个对象实例中.
  2. 让object constructer本身就是从XML文件加载其数据的人.

如果默认情况下不可能,它应该使用反射(在反序列化后复制每个属性),但这将是一个丑陋的解决方案.

.net c# serialization .net-2.0

6
推荐指数
2
解决办法
3734
查看次数

.NET自己的配置文件

有没有办法在运行时指定我想使用的配置文件(除了App.config)?例如,我想从命令行读取第一个参数,该命令行将是应用程序配置的路径,我希望我的应用程序在使用ConfigurationManager.AppSettings时引用它(这可能是不可能的,但仍值得询问).
我找到了这段代码:

System.Configuration.Configuration config
    = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        config.AppSettings.File = myRuntimeConfigFilePath;
        config.Save(ConfigurationSaveMode.Modified);
        ConfigurationManager.RefreshSection("appSettings");
Run Code Online (Sandbox Code Playgroud)

它工作,但它覆盖了原始的App.config的AppSettings部分,我的应用程序不应该写任何东西.

.net c# app-config

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

在 URL 中使用非拉丁字符

我正在开发一个网站,客户已将其翻译成克罗地亚语和斯洛文尼亚语。为了与现有的 URL 模式保持一致,我们生成了模仿应用程序布局的 URL 重写规则,这导致 URL 中出现许多非 ASCII 字符。

\n\n

示例 \xc5\xa1 \xc5\xbe \xc4\x8d

\n\n

有些链接是使用 getURL 从 Flash 触发的,有些是标准 HTML 链接。有些是编程式的 Response.Redirects,有些是通过向响应添加 301 状态代码和位置标头来实现。我正在 IE6、IE7 和 Firefox 3 中进行测试,浏览器间歇性地显示非拉丁字符 url 编码。

\n\n
\xc5\xa1 = %c5%a1\n\xc5\xbe = %c5%be\n\xc4\x8d = %c4%8d\n
Run Code Online (Sandbox Code Playgroud)\n\n

我猜这与 IIS 及其处理 Response.Redirect 和 AddHeader("Location ...

\n\n

有谁知道强制 IIS 不对这些字符进行 URL 编码的方法,或者我最好的选择是用非变音符号替换这些字符?

\n\n

谢谢

\n

asp.net iis-6 friendly-url url-rewriting non-ascii-characters

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

Delphi:如何自动删除未使用的变量("变量'x'已声明但从未使用过"提示)

是否有任何工具(最好是免费软件)可以分析Pascal/Delphi语法并自动删除未使用的变量?

就我而言,我正在使用一个非常大的Delphi代码库,并且编译器提示报告超过一千个"变量'x'被声明但从未使用过".

我需要花费数小时手动删除它们,我可能会犯错误,但正确的工具应该能够安全自动地完成.

我在网上搜索但没找到一个......这里有人知道这样的工具吗?

谢谢...

马克布拉德福德

delphi syntax

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

如何区分Win32插槽手柄与其他管道手柄?

我需要确定我的代码没有创建的句柄GetFileType()==FILE_TYPE_PIPE,是否为套接字.似乎没有这方面的API.

我尝试了以下内容.一般的想法是使用特定于套接字的函数并将失败视为非套接字.

  • getsockopt() - 这是我的第一次尝试.不幸的是,当同一(非套接字)句柄上的许多线程调用时,它似乎挂起.
  • WSAEnumNetworkEvents()- 这就是Gnulib所做的,但如果手柄套接字会产生不良副作用.
  • getpeername() - 这就是cygwin所做的,但是对于一些套接字也会失败.猜测错误是否意味着套接字似乎不可靠且未来安全.

我不介意解决方案是否仅适用于某些版本的Windows,例如Vista,在一般情况下,我总是可以回到其他方法.

winapi winsock

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

WebService添加布尔参数时消耗的WCF?

我在VS2008中创建了默认的WCF服务.它被称为"Service1"

public class Service1 : IService1
{
    public string GetData( int value )
    {
        return string.Format("You entered: {0}", value);
    }

    public CompositeType GetDataUsingDataContract( CompositeType composite )
    {
        if ( composite.BoolValue )
        {
            composite.StringValue += "Suffix";
        }
        return composite;
    }
}
Run Code Online (Sandbox Code Playgroud)

它工作正常,接口是IService1:

[ServiceContract]
public interface IService1
{

    [OperationContract]
    string GetData( int value );

    [OperationContract]
    CompositeType GetDataUsingDataContract( CompositeType composite );

    // TODO: Add your service operations here
}
Run Code Online (Sandbox Code Playgroud)

这是默认情况下的全部; Visual Studio 2008创建了所有这些.

然后我创建了一个简单的Winforms应用程序来"测试"这个.我将服务参考添加到我上面提到的服务中,一切正常.我可以实现并调用myservice1.GetData(100); 我得到了结果.

但有人告诉我,这项服务必须通过Web Services由Winforms .NET 2.0应用程序使用,因此我继续添加对从头创建的新Winforms .NET 2.0应用程序的引用(只有一个名为form1的winform).这次,在添加"web引用"时,它添加了属于webservices的典型"localhost"; 向导看到了WCF服务(在后台运行)并添加了它.

当我尝试使用它时,我发现GetData(int)方法现在是GetData(int,bool). …

c# wcf .net-3.5 visual-studio-2008 .net-2.0

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

Django:默认情况下执行不区分大小写的查找

我需要username在使用Django Auth框架时默认执行不区分大小写的查询.

我尝试通过编写自定义子类Queryset 并重写该_filter_or_exclude方法来修复该问题,然后在User模型的自定义管理器中使用该子类 -

from django.db.models import Manager
from django.db.models.query import QuerySet
from django.contrib.auth.models import UserManager

class MyQuerySet(QuerySet):
    def _filter_or_exclude(self, negate, *args, **kwargs):
        if 'username' in kwargs:
            kwargs['username__iexact'] = kwargs['username']
            del kwargs['username']
        return super(MyQuerySet, self)._filter_or_exclude(negate, *args, **kwargs)

class MyUserManager(UserManager):
    def get_query_set(self):
        return MyQuerySet(self.model)

User.objects = MyUserManager()
Run Code Online (Sandbox Code Playgroud)

但是这种方法不起作用,我在尝试时遇到了一个奇怪的错误User.objects.get(username='Foo').

任何帮助,将不胜感激.

更新:我包含了我得到的确切错误.

/usr/lib/python2.5/site-packages/django/db/models/query.py in get(self, *args, **kwargs)
    295         keyword arguments.
    296         """
--> 297         clone = self.filter(*args, **kwargs)
    298         num = len(clone)
    299         if …
Run Code Online (Sandbox Code Playgroud)

python django django-models django-orm

6
推荐指数
2
解决办法
3295
查看次数

PDF -Adobe Digital Edition

我想使用Adobe Digital Edition保护pdf文档.我认为它目前被用来保护电子书以防止非法流通.

任何人都可以对此有所了解.是否有可能使用C#或其他东西?

c# pdf adobe

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