我找到了一个矩形函数,所有四个角都是圆的,但我想只有前两个角.我能做什么?
canvas.drawRoundRect(new RectF(0, 100, 100, 300), 6, 6, paint);
Run Code Online (Sandbox Code Playgroud) 我有以下列表视图,我想添加一个浮动操作按钮.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background_serious" >
<include layout="@layout/toolbar"/>
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#00000000">
</ListView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_done" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在当前形式中,按钮根本不显示.我尝试过更改LinearLayout为CoordinatorLayout尽可能多的示例.但后来我收到一个错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.sudoq/de.sudoq.controller.menus.SudokuLoadingActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class CoordinatorLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
...
Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class CoordinatorLayout
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
...
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.CoordinatorLayout" on path: DexPathList[[zip file "/data/app/de.sudoq-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]] …Run Code Online (Sandbox Code Playgroud) 我正在(gradle)spring boot 项目中使用 openAPI 实现 petstore API。我使用 openapi 生成器插件生成一个服务器并实现一个简单的请求:
@Service
@RestController
public class PetApiController implements PetApi {
@Override
public ResponseEntity<Pet> getPetById(Long petId) {
Pet p = new Pet();
p.setId(0L);
p.setName("fido");
p.setPhotoUrls(new ArrayList<String>());
p.setStatus(StatusEnum.AVAILABLE);
p.setTags(new ArrayList<Tag>());
Category c = new Category();
c.setId(3L);
c.setName("dummy category");
p.setCategory(c);
ResponseEntity<Pet> r = new ResponseEntity<Pet>(p, HttpStatus.OK);
return r;
}
}
Run Code Online (Sandbox Code Playgroud)
我生成的 swagger-ui 为请求提供了 xml 和 json 查询,但 xml 似乎不起作用:
$ curl -X GET "http://localhost:8080/pet/1" -H "accept: application/xml"; echo ""
$ curl -X GET "http://localhost:8080/pet/1" -H "accept: …Run Code Online (Sandbox Code Playgroud) 我在ubuntu 13.10上使用google android ide adt-eclipse.这很好.当我升级ubuntu 14.04时,当它被用于方法等时,日食会崩溃.日志如下:谁可以帮助我?谢谢!
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f3d9fbaa685, pid=29310, tid=139905366640384
#
# JRE version: 7.0_15-b03
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libwebkitgtk-1.0.so.0+0x407685] webkitWebViewRegisterForIconNotification+0x95
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If …Run Code Online (Sandbox Code Playgroud) 我已经实现了一个onDraw绘制一组矩形的long 方法.矩形太小,我希望它们看起来更大.但不幸的是我无法更改矩形坐标,因为它们存储在数据库中.那么有什么方法可以放大画布使用canvas.scale()?
我在Android Studio中有两个项目:model和app。
model是完全用Java编写的,graddle文件开头apply plugin: 'java'
app是用android-java编写的,并且取决于model。Graddle文件以apply plugin: 'com.android.application'
我可以插入以下代码段:
/**
* Debugging
*
* @throws IllegalArgumentException
* if illegal == true
*/
private void debug(boolean illegal){
if (illegal)
throw new IllegalArgumentException("tu");
}
Run Code Online (Sandbox Code Playgroud)
在任何地方,app没有错误。但是,当我将其插入任何地方时,model都会出现错误:Symbol 'IllegalArgumentException' is inaccessible from here单击“更多”后,
Inspection info: This inspection points out unresolved references inside javadoc
我可以进行编译,而不会出现问题。
我的Android Studio版本是3.4。我不记得以前使用的版本存在此问题,但是我不确定是哪个版本。
我有一个 Spring Boot 应用程序,其中包含通过 gradle 插件生成的 java 客户端:
openApiGenerate {
generatorName = "java"
inputSpec = specsYml
outputDir = "$buildDir/generated".toString()
apiPackage = "com.customapi.api"
invokerPackage = "com.customapi.invoker"
modelPackage = "com.customapi.model"
configOptions = [
dateLibrary: "java8",
library : "resttemplate"
]
}
Run Code Online (Sandbox Code Playgroud)
我选择了"java8"as,dateLibrary因为这似乎是 java 1.8 项目的首选。
使用生成的客户端,我正在执行一个请求,该请求返回一个包含时间戳的对象。我收到以下错误:
java.lang.IllegalStateException: Failed to execute CommandLineRunner
...
Caused by: org.springframework.web.client.RestClientException: Error while extracting response for type [class com.customapi.model.Info] and content type [application/json];
...
Caused by: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type …Run Code Online (Sandbox Code Playgroud) 我想从子文件夹中的文件调用函数.我宁愿做静态的.我使用空__init__.py文件,因为我已经读过,在简单的情况下,它们可能是空的(我的可能不是更简单),或者从3.5开始,我根本不需要它们.但我愿意填补它们.
我有以下文件结构:
test
??? callfoo.py (main)
??? __init__.py (empty)
??? folder
??? submodule.py
??? __init__.py (empty)
Run Code Online (Sandbox Code Playgroud)
callfoo.py:
#import statement wanted
def main():
foo()
if __name__ == "__main__":
main()
Run Code Online (Sandbox Code Playgroud)
submodule.py
def foo():
print('foo')
Run Code Online (Sandbox Code Playgroud)
对于我尝试过的import语句:
import test.folder.submodule
from test.folder import submodule
from test.folder.submodule import foo
每一个导致ModuleNotFoundError: No module named 'test.folder'
我在这里有点困惑,因为它们是直接从文档中获取的
import .folder.submodule- > invalid syntax
importlib.import_module('test.folder.submodule')
ModuleNotFoundError:没有名为'test.folder'的模块
这有效:
import importlib.util
spec = importlib.util.spec_from_file_location("submodule", "/home/.../test/folder/submodule.py")
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
Run Code Online (Sandbox Code Playgroud)
但我真的不想动态地这样做,特别是对于几个文件.
这个ModuleNotFoundError:没有名为x的模块处理我的错误消息,但是根据我的判断,它没有处理子文件夹(对于我来说,submodule.py它在同一级别上工作正常callfoo.py) …
我对矩阵列表求和,foldl1 (+)因为我注意到sum实际上返回的是左上角元素的和为1x1矩阵。
$ stack exec --resolver lts-12.5 --package matrix -- ghci
GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help
Prelude> import Data.Matrix
Prelude Data.Matrix> t = [identity 2, identity 2] -- two 2x2 identity matrices
Prelude Data.Matrix> foldl1 (+) t
? ?
? 2 0 ?
? 0 2 ?
? ?
Prelude Data.Matrix> sum t
? ?
? 2 ?
? ?
Run Code Online (Sandbox Code Playgroud)
这对我来说是出乎意料的,LYAH建议sum = foldl1 (+)¹甚至hlint建议我使用sum而不是foldl1 (+)' Removing error on …
我想我可以从这个问题中推断出来,但我不能
我当然可以
short[] shortarray = {0,1,2};
List<Short> shortList = new ArrayList<Short>();
for (Short s : shortarray) {
shortList.add(s);
}
Run Code Online (Sandbox Code Playgroud)
但我想知道如何用流来做到这一点。
List<Short> shortList = Arrays.stream(shortarray).boxed()
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
例如不起作用,但会产生 The method stream(T[]) in the type Arrays is not applicable for the arguments (short[])
android ×4
java ×3
spring-boot ×2
draw ×1
eclipse ×1
fold ×1
foldable ×1
haskell ×1
jackson ×1
java-stream ×1
matrix ×1
python-3.x ×1
scale ×1
spring ×1
sum ×1
ubuntu-14.04 ×1
zoom ×1