我目前正在寻找JAVA的职业生涯,并决定从构建应用程序开始.我在这里有这个代码,我用它来触发语音识别.
public class MainActivity extends Activity implements OnClickListener{
private static final int VR_REQUEST = 999;
private ListView wordList;
private final String LOG_TAG = "SpeechRepeatActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button speechBtn = (Button) findViewById(R.id.speech_btn);
wordList = (ListView) findViewById (R.id.word_list);
PackageManager packManager= getPackageManager();
List<ResolveInfo> intActivities = packManager.queryIntentActivities
(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
if (intActivities.size() !=0){
speechBtn.setOnClickListener(this);
} else {
speechBtn.setEnabled(false);
Toast.makeText(this,"Oops - Speech Recognition Not Supported!",
Toast.LENGTH_LONG).show();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this …Run Code Online (Sandbox Code Playgroud) 在我的LogCat上运行两次名为":无法打开文件进行读取"的Galaxy s3时,我收到错误.
这是我的代码:package com.example.speechrecognizertest;
import android.os.Bundle;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.TextView;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
public static final String TAG = null;
private ListView wordList;
private SpeechRecognizer mSpeechRecognizer;
private Intent mSpeechRecognizerIntent;
private boolean mIslistening;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button speechBtn = (Button) findViewById(R.id.speech_btn);
wordList = …Run Code Online (Sandbox Code Playgroud) 出于某种原因\n在javascript中不适合我.无论如何要修复它或使用HTML?在我的情况下,我认为使用<br>将无法在我的href中工作.你有什么建议.
在这里工作JSFiddle .
HTML:
<a id = 'emailoff' href = "" target = "_blank">
<div id= "btn1">
<h2 id = "enter">Send Email</h2>
</div>
</a>
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
$('#btn1').click(function() {
$("#emailoff").attr("href", "mailto:" +
"?subject=Your ThinOptics glasses" +
"&body=To get your new ThinOptics glasses simply click this link and pick the case and color you like best. You'll get free shipping on your order. \n"+
" WWw.Thinoptics.Com/teddy@shalon.com \n" +
"\n Enjoy")
});
Run Code Online (Sandbox Code Playgroud) 所以我正在运行.click jQuery事件.出于某种原因,它会在网站加载时开始调用,然后在此之后不会"激活"或响应.我尝试将其更改为.hover,不确定原因,但没有任何效果.我不知道该往哪里去.它与css中的定位有关吗?我想它可能但不确定如何弄明白.我只会显示与此问题相关的html,javascript和css,如果您想查看其他内容,请告诉我.
HTML:
<img id = "logo" style="float: left;" src="img/logo.png" alt="logo" width="72.5" height="100">
Run Code Online (Sandbox Code Playgroud)
CSS:
#logo{
position: fixed;
right: 90%;
top: 5%;
}
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
$( document ).ready(function() {
$("#logo").click(function(){console.log("logo was clicked");});
});
Run Code Online (Sandbox Code Playgroud)
再说一次,我认为它可能与css中的定位有关...请让我知道你的想法.我可能正在做一些愚蠢的事情,我只是没有注意到.
我的代码遇到了问题.我想编辑一个元素的href.我需要它来点击预先制作的主题和正文时发送你的电子邮件.我收到错误"Unexpected token ILLEGAL"但我完全不确定原因.
我希望有人可以帮我解决这个问题.
我需要在javascript中编辑这个属性,所以把它放在要开始的元素中是行不通的!
有一个的jsfiddle 这里.
这是我的:
HTML:
<a id = 'emailoff' href = "" target = "_blank">
<div id= "btn1">
<h2 id = "enter">Send Email</h2>
</div>
</a>
Run Code Online (Sandbox Code Playgroud)
JAVASCRIPT:
$('#btn1').click(function(){
$("#emailoff").attr("href", "mailto: email@email.com
?subject=Your thinoptics glasses
body=To get your new thinoptics glasses simply click this link and pick the case and color you like best. You'll get free shipping on your order
WWw.Thinoptics.Com/email@email.com
Enjoy")
});
Run Code Online (Sandbox Code Playgroud)
更新:
错误在:"mailto:email@email.com ......"