问题列表 - 第46253页

如何在运行时获取铃声首选项?

我有以下xml:

 <?xml version="1.0" encoding="utf-8"?>
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="Ringtone preference" android:key="ringtone_option_preference">
    <RingtonePreference 
    android:key="ring_tone_pref"
    android:title="Set Ringtone Preference"
    android:showSilent="true"
    android:ringtoneType="notification"
    android:summary="Set Ringtone"/>
 </PreferenceScreen>
Run Code Online (Sandbox Code Playgroud)

我希望每次通知即将显示时,要查看铃声的值并相应地发出蜂鸣声:)...更准确地说,我的通知是在broadcastReceiver类中生成的,每次接收器捕获的内容都会创建一个新通知...我只想根据首选项中设置的铃声更改通知的铃声.

我怎样才能做到这一点?

谢谢

麦克风

android preferences ringtone android-preferences

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

使用jquery ajax将参数传递给控制器

我创建了一个视图和一个控制器,控制器我想要返回一些搜索结果.我使用jquery调用控制器

   <input type="text" id="caption" />
        <a href="#" id="search">Search</a>
        <script>
            $("#search").click(function () {
                alert('called');
                var p = { Data: $('#search').val() };
                $.ajax({
                    url: '/Ingredients/Search',
                    type: "POST",
                    data: JSON.stringify(p),
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    success: function (data) {
                        alert(data);
                    },
                    error: function () {
                        alert("error");
                    }
                });
            });
Run Code Online (Sandbox Code Playgroud)

我的控制器看起来像这样

 [HttpPost]
    public ActionResult Search(string input)
    {
        var result = _db.Ingredients.Where(i => i.IngredientName == input);

        return new JsonResult() {Data = new {name="Hello There"}};
    }
Run Code Online (Sandbox Code Playgroud)

我的问题是我不知道如何从我的jquery调用中获取varible进入控制器,我在控制器上放置了一个断点并且它被命中但是输入字符串始终为null.

我做错了什么?

jquery asp.net-mvc-3

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

散列表Python中的元组与数组

我听说元组元素占用空间不足但无法修改,因此在执行时间方面最佳解决方案是什么:

hash = {}
hash['foo'] = [34,'foobar',[55,90]]
hash['foo'][0] = hash['foo'][0] + 17
Run Code Online (Sandbox Code Playgroud)

要么

hash = {}
hash['foo'] = (34,'foobar',[55,90])
hash['foo'] = (hash['foo'][0] + 17,hash['foo'][1],hash['foo'][2])
Run Code Online (Sandbox Code Playgroud)

python

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

在一些Sub-XAML文件中拆分一个大的XAML

在我的基于桌面的WPF4应用程序中,有一个带有侧边栏菜单的大块,在每个窗口中重复,大约需要70行XAML.为了提高代码重用率,我想将XAML文件拆分为两个文件:

  1. 包含侧边栏菜单代码的XAML文件(≈70行)
  2. 基本XAML文件,包含带有侧边栏菜单代码的XAML文件的"include/reference"

据我所知,有两种方法可以解决我的问题:

  1. 使用 ResourceDictionary
  2. 使用UserControl/CustomControl

我的问题是:

  1. ResourceDictionary和之间有什么区别UserControl?你能给我的例子,我必须用UserControl在哪里ResourceDictionary

  2. 你能给出一个完整的代码示例,如何将一个XAML文件的内容包含/导入到其他文件中?

PS以下是我要导出到单独的XAML文件的代码示例:

<Border Style="{StaticResource Body_SideBarMenu_Border_Settings}">
    <StackPanel Style="{StaticResource Body_SideBarMenu}">

    <TextBlock Style="{StaticResource Body_SideBarMenu_Title}"
           Text="{x:Static res:Resources.WinApp_SideBarMenu_Title}" />

        <TextBlock x:Name="SideBar_WinReports"
               Style="{StaticResource Body_SideBarMenu_Item}"
               Text="{x:Static res:Resources.DashListMarker}">
                    <Hyperlink KeyboardNavigation.TabIndex="12"
                           Style="{StaticResource Body_SideBarMenu_Item_Hyperlink}"
                           Click="Call_WinReports_Click">
                            <TextBlock Text="{x:Static res:Resources.WinApp_ModuleName_Reports}" />
                    </Hyperlink>
        </TextBlock>

    </StackPanel>
</Border>
Run Code Online (Sandbox Code Playgroud)

wpf code-reuse xaml user-controls resourcedictionary

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

表圆角问题

我在圆角桌上剥皮有些问题.

请看一下图片: 在此输入图像描述

这里是代码:

<table id="whitePanel" width="190px" cellpadding="0" cellspacing="0" border="0" >
<tr>
    <td>
        <img src="assets/images/lightRoundedCorners/tl.png" width="8" height="8" border="0" alt="..." />
    </td>
    <td>
        <img src="assets/images/lightRoundedCorners/t.png"  alt="..." height="8" width="100%" />
    </td>
    <td>
        <img src="assets/images/lightRoundedCorners/tr.png" width="8" height="8" border="0" alt="..." />
    </td>
</tr>
<tr>
    <td>
        <img src="assets/images/lightRoundedCorners/l.png" width="8" alt="..." height="100%" border="0"/>
    </td>
    <td align="center" border="0" style="background: url(assets/images/lightRoundedCorners/c.png) repeat">
        ACTUAL CONTENT
        <p>1. Item 1</p>
        <p>1. Item 1</p>
        <p>1. Item 1</p>
    </td>
    <td>
        <img src="assets/images/lightRoundedCorners/r.png" width="8" alt="..." height="100%" border="0"/>
    </td>
</tr>
<tr>
    <td>
        <img src="assets/images/lightRoundedCorners/bl.png" width="8" height="8" …
Run Code Online (Sandbox Code Playgroud)

html css rounded-corners

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

ASP.net 在 XDocument 中创建 XLink 节点

我正在尝试以编程方式向 XDocument 添加一个新的 XLink 节点,但 .Net 似乎将它们创建为原子化的命名空间和名称,我找不到任何代码将 XLink 节点添加到 XML?

我的代码如下所示:

//read in the current XML content
XDocument content = XDocument.Parse(xmlContent);

//add a new node called large images
XElement newNode = new XElement("large_images", "");
newNode.SetAttributeValue("{xmlns}xlink", "http://www.w3.org/1999/xlink");
newNode.SetAttributeValue("{xlink}type", "simple");
newNode.SetAttributeValue("{xlink}href", "tcm:5-550");
newNode.SetAttributeValue("{xlink}title", "of1_454x340.jpg");
content.Add(newNode);
Run Code Online (Sandbox Code Playgroud)

不幸的是,这个 newNode 是这样出现的:

<large_images p1:xlink="http://www.w3.org/1999/xlink" p2:type="simple" p2:href="tcm:5-550" p2:title="of1_454x340.jpg" xmlns:p2="xlink" xmlns:p1="xmlns"></large_images>
Run Code Online (Sandbox Code Playgroud)

但我需要节点看起来像这样才能通过 XML 验证:

<large_images xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="tcm:5-550" xlink:title="of1_454x340.jpg"></large_images>
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?我不想走 String.Replace() 路线,因为这似乎必须是另一种方式?

谢谢

瑞安

c# asp.net linq-to-xml xlink

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

python twitter Api()找不到错误

我正在尝试使用python-twitter模块,但仍然在启动twitter.Api()时遇到问题.我已经检查并重新检查了我的系统上没有其他名为twitter.py或twitter.pyc的文件.在干净的安装我首先尝试

>>> import twitter 
Run Code Online (Sandbox Code Playgroud)

并正确得到'模块未知'的响应

我做了easy_install twitter,成功了.

然后做

>>> import twitter
>>> testapi = twitter.Api()
Run Code Online (Sandbox Code Playgroud)

回应是

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    testapi = twitter.Api()
AttributeError: 'module' object has no attribute 'Api'
>>> 
Run Code Online (Sandbox Code Playgroud)

我很累,试图在这里找到问题,请帮忙.

python api twitter

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

陷入ManagedBeanPreProcessingException:处理托管bean的意外错误

任何人都可以帮助我们吗?

我们正在尝试在JSF应用程序中创建注册用户功能.我们希望用户在注册后立即登录.用户点击我是一个新的客户端commandLink后,我们有这个例外,我们不知道如何处理它:

com.sun.faces.mgbean.ManagedBeanPreProcessingException: Unexpected error processing managed bean registerBean
    at com.sun.faces.mgbean.BeanManager.preProcessBean(BeanManager.java:394)
    at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:260)
    at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:175)
    at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
    at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:99)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:158)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
    at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:102)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:190)
    at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:178)
    at javax.faces.component.UIOutput.getValue(UIOutput.java:168)
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:338)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:878)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1620)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:848)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1613)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1616)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:380)
    at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:126)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:127)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:313)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at …
Run Code Online (Sandbox Code Playgroud)

java jsf jsf-2

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

检查有效的SQL列名称

你如何在php中检查字符串是否是sql语句的有效兼容列名?只是一个字符串匹配.

php mysql sqlite postgresql

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

在iPhone设备上调试时是否可以使用终端malloc_history?

我发现malloc_history在iOS模拟器上测试时很有用,是否可以为物理设备(iPhone 4)配置它.

控制台上我得到类似的消息

warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
Run Code Online (Sandbox Code Playgroud)

我需要在某处设置此文件吗?

终端上我得到了这个

malloc_history cannot examine process xxxx because the process does not exist.
Run Code Online (Sandbox Code Playgroud)

任何直接的建议/指向文档将不胜感激.

谢谢

iphone debugging terminal console

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