问题列表 - 第28526页

如何获得在Android中工作的偏好设置?

我真的在努力解决这个问题.Java/Android新手.我正在编写我的第一个应用程序,这是第一件让我花费超过几天寻找的应用程序.这是设置:这是一个BAC计算器/饮料柜台:

替代文字

公式用于计算BAC.这是论坛:

Bac = ((StandardDrinks / 2) * (GenderConstant / Weight)) - (0.017 * Hours);
Run Code Online (Sandbox Code Playgroud)

如您所见,能够修改性别和体重将产生更准确和个性化的结果.所以我把它们作为双打:

double GenderConstant = 7.5; //9 for female
double Weight = 180;
Run Code Online (Sandbox Code Playgroud)

要更改这些变量,我希望此人能够进入设置并选择不同的值.我已经设置了这些东西,但没有链接到上面显示的变量,因为我不能为我的生活弄清楚如何.他们来了:

替代文字

我按下菜单按钮,然后弹出.大.我将点击"设置".

替代文字

现在弹出首选项.这是我的preferences.xml:

<?xml version="1.0" encoding="utf-8"?>
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

 <PreferenceCategory android:title="Personal Settings">


 <ListPreference
 android:title="Gender"
 android:summary="Verify or deny the presence of a Y chromosome."
 android:key="genderPref"
 android:defaultValue="male"
 android:entries="@array/genderArray"
 android:entryValues="@array/genderValues" />

 <ListPreference
 android:title="Weight"
 android:summary="How much the planet pulls on you, in pounds."
 android:key="weightPref"
 android:defaultValue="180"
 android:entries="@array/weightArray"
 android:entryValues="@array/weightValues" />

 </PreferenceCategory>

<PreferenceCategory android:title="Drink Settings">

 <ListPreference
 android:title="Beer Size"
 android:summary="The volume of …
Run Code Online (Sandbox Code Playgroud)

variables settings android preferences sharedpreferences

24
推荐指数
2
解决办法
5万
查看次数

帮助优化SQL查询

我有跟踪表tbl_track与id,session_id,created_date字段

我需要计算一天的唯一session_id

在这里我得到了:

select count(0) 
from (
       select distinct session_id
       from tbl_track 
       where created_date between getdate()-1 and getdate()
       group by session_id
)tbl
Run Code Online (Sandbox Code Playgroud)

我觉得它可能是更好的解决方案

sql database sql-server optimization

0
推荐指数
2
解决办法
111
查看次数

如何确定图像中是否存在图像?

我有一个NSStrings 数组:

Flower
Car
Tree
Cat
Shoe
Run Code Online (Sandbox Code Playgroud)

其中一些字符串具有与之关联的图像; 有些人没有.我可以通过附加.png名称(例如Flower.png)来构建图像名称.

在尝试将图像加载到视图中之前,如何检查图像中是否存在该图像?

iphone cocoa-touch objective-c nsstring uiimage

5
推荐指数
2
解决办法
6638
查看次数

删除NSLog会破坏编译器

好的,所以这很奇怪

我有这个代码

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
  case 1:
    NSLog(@"Platform Cell Selected");
    AddGamePlatformSelectionViewController *platformVC =
      [[AddGamePlatformSelectionViewController alloc]
      initWithNibName:@"AddGamePlatformSelectionViewController" bundle:nil];
    platformVC.context = context;
    platformVC.game = newGame;
    [self.navigationController pushViewController:platformVC animated:YES];
    [platformVC release];
    break;
  default:
    break;
  }
}
Run Code Online (Sandbox Code Playgroud)

哪个工作正常.

当我删除NSLog语句时,如下所示:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
  case 1:
    //NSLog(@"Platform Cell Selected");
    AddGamePlatformSelectionViewController *platformVC =
      [[AddGamePlatformSelectionViewController alloc]
      initWithNibName:@"AddGamePlatformSelectionViewController" bundle:nil];
    platformVC.context = context;
    platformVC.game = newGame;
    [self.navigationController pushViewController:platformVC animated:YES];
    [platformVC release];
    break;
  default:
    break;
  }
}
Run Code Online (Sandbox Code Playgroud)

我得到以下编译器错误

/Users/DVG/Development/iPhone/Backlog/Classes/AddGameTableViewController.m:102:0 …

iphone nslog uitableview

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

文字控制高度和宽度吗?

在我的应用程序中,我正在数据列表中使用文字控件,现在我想为文字控件应用高度和宽度,是否有可能将高度和宽度应用于文字控件。谢谢。

asp.net

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

在ASP.NET窗体身份验证中更改用户密码

我在C#(ASP.NET)中编码并使用Forms身份验证.
我想知道哪个是更改用户密码的最佳方法,而不使用asp:ChangePassword控件.
我不想使用重置密码方法.
我只想获取文本框中的密码并将其替换为旧密码.
请注意我使用的PasswordFormat是passwordFormat ="Hashed"
一些代码片段会有所帮助

编辑:

在我的web.config中,我设置了enablePasswordRetrieval ="false"
我使用了以下方法

var myUser = Membership.GetUser(userID);
bool isChangeSuccess = myUser.ChangePassword(
    myUser.GetPassword(),
    ActivateUserPasswordText.Text.Trim());
Run Code Online (Sandbox Code Playgroud)

它给了我错误,

此成员资格提供程序尚未配置为支持密码检索.

可以做些什么来解决这些问题?我真的希望我的PasswordFormat是哈希本身.

此致,
Naveen Jose

c# asp.net forms-authentication

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

git mv并且只更改目录的大小写

虽然我发现了类似的问题,但我找不到问题的答案

当我尝试将目录从FOO重命名为foo时,git mv FOO foo我得到了

fatal: renaming 'FOO' failed: Invalid argument
Run Code Online (Sandbox Code Playgroud)

好.所以我试试git mv FOO foo2 && git mv foo2 foo

但当我尝试通过git commit .我得到

# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# foo
nothing added to commit but untracked files present (use "git add" to track)
Run Code Online (Sandbox Code Playgroud)

当我通过git add foo无变化添加目录并git commit .再次给我相同的消息.

我究竟做错了什么?我以为我使用区分大小写的系统(OSX)为什么我不能简单地重命名目录?

git macos version-control case-sensitive

250
推荐指数
7
解决办法
7万
查看次数

为了清晰起见,从功能中返回enum而不是bool?

这类似于:

.NET:bool vs enum作为方法参数

但是担心在某些情况下从函数返回bool.

例如返回bool的函数:

    public bool Poll()
    {
        bool isFinished = false;

        // do something, then determine if finished or not.

        return isFinished;
    }
Run Code Online (Sandbox Code Playgroud)

像这样使用:

        while (!Poll())
        {
            // do stuff during wait.
        }
Run Code Online (Sandbox Code Playgroud)

从调用上下文来看,从Poll()返回的bool意味着什么并不明显.如果"轮询"功能被重命名为"IsFinished()",在某些方面可能更清楚,但该方法做了一些工作,并且(IMO)不会真正反映该功能实际上做了什么.像"IsFinished"这样的名字似乎也更适合于属性.另一种选择可能是将其重命名为:"PollAndReturnIsFinished",但这也感觉不对.

所以一个选项可能是返回枚举.例如:

    public enum Status
    {
        Running,
        Finished
    }  

    public Status Poll()
    {
        Status status = Status.Running;

        // do something, then determine if finished or not.

        return status;
    }
Run Code Online (Sandbox Code Playgroud)

这样称呼:

        while (Poll() == Status.Running)
        {
            // do stuff during wait.
        }
Run Code Online (Sandbox Code Playgroud)

但这感觉有点矫枉过正.有任何想法吗 ?

c# coding-style

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

perl read()函数和缓冲区背后的魔力是什么?

我不明白Perl read($ buf)函数如何能够修改$ buf变量的内容.$ buf不是引用,因此参数由copy(来自我的c/c ++知识)给出.那么为什么在调用者中修改$ buf变量呢?

它是一个平局变量还是什么?关于setbuf的C文档对我来说也是非常难以理解的

# Example 1
$buf=''; # It is a scalar, not a ref
$bytes = $fh->read($buf);
print $buf; # $buf was modified, what is the magic ?

# Example 2
sub read_it {
    my $buf = shift;
    return $fh->read($buf);
}
my $buf;
$bytes = read_it($buf);
print $buf; # As expected, this scope $buf was not modified
Run Code Online (Sandbox Code Playgroud)

io perl buffer handle

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

Haskell多线程有多难?

我听说在Haskell中,创建一个多线程应用程序就像采用标准的Haskell应用程序并使用-threaded标志编译它一样简单.但是,其他情况描述了par在实际源代码中使用命令.

Haskell多线程的状态是什么?引入程序有多容易?是否有一个很好的多线程教程可以解决这些不同的命令及其用途?

concurrency multithreading haskell multicore

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