小编aha*_*aha的帖子

更改ProgressDialog的背景

我想改变一个的背景ProgressDialog.我在网上搜索并找到了各种建议(比如如何从Dialog中删除边框?),但是我无法替换它的实际背景ProgressDialog.相反,我在对话框后面得到另一个背景(黄色):

样式对话框

我的风格:

<style name="StyledDialog" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@drawable/panel_background</item>
</style>
Run Code Online (Sandbox Code Playgroud)

启动以下代码ProgressDialog:

ProgressDialog dialog = new ProgressDialog(this, R.style.StyledDialog);
dialog.setTitle("The title");
dialog.setMessage("The message.");
dialog.show();
Run Code Online (Sandbox Code Playgroud)

drawable与SDK中包含的9个补丁相同,我只是改为颜色.我非常感谢一些暗示我做错了什么.

android android-layout android-dialog

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

具有Web应用程序上下文的Spring上下文层次结构

我正在处理一个Spring MVC Web应用程序,该应用程序是使用一个引导程序DispatcherServlet.它创建了一个XmlWebApplicationContext管理整个应用程序:

<servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:springmvc-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
Run Code Online (Sandbox Code Playgroud)

现在有一些模块应该在运行时使用a加载ContextSingletonBeanFactoryLocator.因此每个模块都有自己的模块ClasspathXmlApplicationContext.因此,一个模块可以从中引用bean XmlWebApplicationContext,它应该附加到XmlWebApplicationContext形成一个Context Hierarchy,其中XmlWebApplicationContext应该扮演父级角色和ClasspathXmlApplicationContext模块子角色的角色.不幸的是我无法使用它们连接它们

<beans>
    <bean id="moduleContext"
        class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg>
            ...
        </constructor-arg>
        <constructor-arg ref="parentContext" />
    </bean>
</beans>
Run Code Online (Sandbox Code Playgroud)

因为到目前为止我找不到WebApplicationContext这个名字parentContext.我是否忽略了某些东西,或者是否有更好/更简单的方式以不同的方式实现同​​样的目标?

java spring spring-mvc

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

Spring Data JPA:删除乐观锁定语义

Foo一个@Version列的实体.如果我想删除它,我希望Spring Data JPA和/或Hibernate检查@Version列的当前值是否与数据库中的值匹配.如果没有,则应拒绝删除.这与预期的分离实体一起工作:

@Transactional
public void delete(Foo foo) {
    fooRepository.delete(foo); // throws ObjectOptimisticLockingFailureException
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我首先从存储库加载实体,然后使用不同的版本在同一事务中删除它,则无论@Version列的值如何,删除都会通过:

@Transactional
public void delete(int fooId, long version) {
    Foo foo = fooRepository.findOne(fooId);
    foo.setVersion(version);
    fooRepository.delete(foo); // passes regardless of value of version
}
Run Code Online (Sandbox Code Playgroud)

当我查看Hibernate调试输出时,执行版本比较(delete from foo where id=? and version=?)但不是我期望的效果.

我错过了什么?

java hibernate jpa spring-data-jpa

8
推荐指数
2
解决办法
2092
查看次数

React/TypeScript:通过HOC消耗上下文

我正在尝试使用 TypeScript(2.8)中的React文档(React 16.3)中的HOC实现示例Consuming Context,并且失败了.作为参考,来自React手册的代码:

const ThemeContext = React.createContext('light');

// This function takes a component...
export function withTheme(Component) {
  // ...and returns another component...
  return function ThemedComponent(props) {
    // ... and renders the wrapped component with the context theme!
    // Notice that we pass through any additional props as well
    return (
      <ThemeContext.Consumer>
        {theme => <Component {...props} theme={theme} />}
      </ThemeContext.Consumer>
    );
  };
}
Run Code Online (Sandbox Code Playgroud)

我能想到的最好的:

export interface ThemeAwareProps {
  theme: string;
}

const ThemeContext = React.createContext('light');

export …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs

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

在传统的基于 Servlet 的 Spring 应用程序中使用 Spring RSocket

如果不混合这两种变体,是否可以在“传统”的基于 servlet 的 Spring 应用程序中使用Spring 的 RSocket 集成,而不必牺牲 Spring 根据文档提供的功能?

如果是这样,怎么办?有什么陷阱需要注意吗?

目标是允许现有的基于 Servlet 的 Spring 应用程序通过 RSocket 与各种客户端通信。服务器端既不需要也不需要完全反应式的背压体验。必须启动一个与 servlet 容器一起运行的单独的基于 Netty 的服务器是可以接受

为了解决评论中提出的问题,有一些我特别关心的功能:

  • 声明式事务支持是否适用于通过 RSocket 传入的请求,而无需使用 R2DBC?根据Spring 的反应式事务,命令式事务管理和反应式事务管理存在显着差异。
  • Spring Security“只是”工作吗?或者是否需要特殊配置,例如,用于@PreAuthorize由应用程序的基于 servlet 的部分基于 RSocket 的部分调用的方法?

java spring spring-security spring-boot spring-rsocket

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

更改可聚焦 ViewGroup 中元素的读取顺序

我的应用程序中有一些屏幕,TalkBack 无法推断出正确的阅读顺序。根据文档,我可以使用android:accessibilityTraversalAfter和朋友来改变阅读顺序。但它对我来说不适用于可聚焦的元素,ViewGroup这些元素应该一起阅读。

整个布局如下所示:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:accessibilityTraversalBefore="@id/before"
    android:focusable="true"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/before"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:accessibilityTraversalAfter="@id/before"
        android:text="Before"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

    <TextView
        android:id="@+id/after"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:accessibilityTraversalBefore="@id/after"
        android:text="After"
        app:layout_constraintBottom_toTopOf="@+id/before"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

它呈现After在屏幕中间的Before底部。我希望 TalkBack 将整个屏幕视为单个连续元素,因此我设置android:focusabletrue. 默认情况下,TalkBack 读取为:“之后,之前”。但我希望它读作“之前,之后”。虽然我添加了android:accessibilityTraversalBeforeand android:accessibilityTraversalAfter,但它仍然显示为“之后,之前”。这是节点树调试的输出:

TreeDebug: (-2147455381)429.FrameLayout:(0, 0 - 1080, 1920):A
TreeDebug:   (30189)429.TextView:(42, 101 - 397, 172):TEXT{My Application}:A:supportsTextLocation
TreeDebug:   (31150)429.ViewGroup:(0, 210 …
Run Code Online (Sandbox Code Playgroud)

android accessibility android-layout android-view talkback

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