我正在尝试使用Toast
内部OnCLickListener
.我的代码触发以下错误:
The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new View.OnClickListener(){}, String, int)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
Button register = (Button) findViewById(R.id.register);
register.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
EditText name = (EditText)findViewById(R.id.name);
String Lname = name.getText().toString();
Toast.makeText(this, Lname, Toast.LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud) 从helm init
版本 3 开始,该命令不再起作用。运行helm --help
列出所有可用命令,其中init
不再存在。
这是为什么?
我已经创建AbstractActivity
并AbstractFormActivity
删除了一些样板代码,它们的内容可能与问题无关,但无论如何我都会发布它,也许我误解了一些东西,它们是:
public abstract class AbstractActivity extends ActionBarActivity {
protected ObjectGraph graph;
@Inject
public Bus bus;
@Inject
public App app;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(getLayout());
setupInjection();
}
public void setupInjection() {
graph = ((App) getApplication()).createScopedGraph(getModule());
graph.inject(this);
bus.register(this);
ButterKnife.inject(this);
}
protected abstract Object getModule();
protected abstract int getLayout();
}
Run Code Online (Sandbox Code Playgroud)
和
public abstract class AbstractFormActivity<T extends EntidadeBase> extends AbstractActivity implements Form<T> {
protected T entity;
protected Map<View, Boolean> formValidations;
protected AbstractFormActivity() {
formValidations …
Run Code Online (Sandbox Code Playgroud) 我有我的实体与Spring Data JPA,但为了生成关于它们的统计数据,我在Spring中使用jOOQ @Repository
.
由于我的方法返回List
实体或a Double
,我如何将它们作为链接公开?假设我有一个User
实体,我想获得以下JSON:
{
"_embedded" : {
"users" : [ ]
},
"_links" : {
"self" : {
"href" : "http://localhost:8080/api/users"
},
"stats" : {
"href" : "http://localhost:8080/api/users/stats"
}
"profile" : {
"href" : "http://localhost:8080/api/profile/users"
}
},
"page" : {
"size" : 20,
"totalElements" : 0,
"totalPages" : 0,
"number" : 0
}
}
Run Code Online (Sandbox Code Playgroud)
在http:// localhost:8080/api/users/stats中,我想获得一个链接列表,其中包含我在jOOQ存储库中声明的方法.我该如何处理?谢谢.
我了解了GraalVM和SubstrateVM框架。据我了解,该native-image
命令可用于从 Java 源文件创建本机应用程序,如下所示:
$ javac Hello.java
$ native-image --no-server --no-fallback Hello
$ ./hello
Hello World!
$
Run Code Online (Sandbox Code Playgroud)
这将创建一个本机二进制文件hello
,根据这个问题,它由 SubstrateVM 框架提供支持,该框架提供了...
...在没有 JVM 的情况下实际运行提前编译的 Java 字节码所需的其他东西(运行时)。
我不清楚:
hello
由纯目标机字节码组成,还是仍然有 Java 字节码和嵌入的成熟虚拟机(即 SubstrateVM)?hello
相比,运行本机映像需要哪些开销?Hello World!
我在两台设备上安装了Skype
(2.8.0.920
)Android
.第一台设备配备Android 2.2,第二台配备4.04.
当我通过执行以下代码发起呼叫时......
Intent skype_intent = new Intent("android.intent.action.CALL_PRIVILEGED");
skype_intent.setClassName("com.skype.raider", "com.skype.raider.Main");
skype_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
skype_intent.setData(Uri.parse("tel:PassportCard"));
act.startActivity(skype_intent);
Run Code Online (Sandbox Code Playgroud)
... Skype开始拨号并在2秒后挂断.
但是,如果我用前一个替换当前(2.8.0.920
)Skype版本,代码工作正常.
为什么是这样?有帮助吗?
我正在尝试使用该android.net.rtp
库来制作VoIP应用程序.它的音频流可以正确发送和接收.
我的问题是:被叫方手机的扬声器工作正常,但耳机始终静音(即使我关闭扬声器).
我的代码:
AudioManager Audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
Audio.setMode(AudioManager.MODE_IN_COMMUNICATION);
Audio.setSpeakerphoneOn(true);
Audio.setMicrophoneMute(false);
sender = new RtpStreamSender(null, "169.0.199.19", AudioCodec.PCMU);
Run Code Online (Sandbox Code Playgroud) 我正在尝试Thread
在我的项目中发送电子邮件.当我点击a时Button
,a Thread
启动并ProgressBar
显示a.所有邮件一发送,ProgressBar
就不会消失.
这是我的代码:
Button btnSendMail = new Button("Mail");
btnSendMail.addClickListener(this);
@Override
public void buttonClick(ClickEvent event) {
if(event.getButton() == btnSendMail){
sendMail();
}
}
}
private void sendMail(){
List<String> list = new ArrayList<String>();
list.add("mymail@domain.com");
list.add("metoyou@domain.com");
list.add("thisismymail@domain.com");
new Thread(){
public void run(){
while(!isInterrupt()){
progressbar.setVisible(true);
for(String send : list){
new SendMailClass(send); //javamail class
}
progressbar.setVisible(false);
interrupt();
}
}.start();
}
Run Code Online (Sandbox Code Playgroud)
如何控制ProgressBar
分离的可见性Thread
?
我有一个HTTP客户端向POST
服务器发送许多请求.服务器响应所有请求201 Created
和响应正文.就我的目的而言,响应标题就足够了,因为我只对Location
标题感兴趣.我想避免服务器生成响应主体以显着减少网络流量.
根据RFC 7231,...
[...] if one or more resources has been created on the origin server as a
result of successfully processing a POST request, the origin server
SHOULD send a 201 (Created) response containing a Location header [...]
Run Code Online (Sandbox Code Playgroud)
...,因此,我认为,服务器也可以回复例如204 No Content
,省略身体.
因此我的问题是:是否有可能构建一个POST
使服务器响应204 No Content
或以另一种方式省略响应体的请求?
更新1:服务器端是一个Spring Data REST项目,我可以自由配置它.我知道我可以设置RepositoryRestConfiguration#setReturnBodyOnCreate
到false
,但它会影响所有传入的请求,这将是过头了.因此,我更愿意在客户端做出决定.
我有几个月没有使用 react-native。看起来有些事情同时发生了变化。在官方文档中,他们建议卸载react-native-cli
并使用npx react-native init
。我这样做了,但最终出现错误,因为我没有全局安装该软件包。但是,如果我react-native
全局安装,运行项目时会报错,说我应该删除全局包。
现在创建 React 应用程序的正确方法是什么?
android ×5
java ×3
graalvm ×1
headset ×1
http ×1
ios ×1
iphone ×1
jakarta-mail ×1
jooq ×1
jpa ×1
kubernetes ×1
mobile ×1
oncreate ×1
post ×1
progress-bar ×1
react-native ×1
rtp ×1
skype ×1
speaker ×1
spring ×1
spring-boot ×1
substratevm ×1
toast ×1
vaadin7 ×1