menu_chat.xmlです。
java
1<item android:id="@+id/action_voice_input" 2android:title="@string/action_voice_input" 3android:ico="@drawable/ic_action_voice_input" 4app:showAsAction="ifRoom"/>
itemの部分に、Element must be declaredとエラーが出ます。
終了タグに問題があるのかと思ったのですが、違いました。
ChatActivityです。(java)
java
1 @Override 2 public boolean onOptionsItemSelected(MenuItem item) { 3 // Handle action bar item clicks here. The action bar will 4 // automatically handle clicks on the Home/Up button, so long 5 // as you specify a parent activity in AndroidManifest.xml. 6 int id = item.getItemId(); 7 8 //noinspection SimplifiableIfStatement 9 if (id == R.id.action_voice_input) { 10 11 Intent intent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 12 startActivityForResult(intent,0); 13 return true; 14 } 15 16 return super.onOptionsItemSelected(item); 17 }
can not resolve symbol action_voice_input とでます。
File → Invalidate Caches / Restart...のような対応をしたのですが、ダメでした。
コンソールです。
java
1Error:(4) Error parsing XML: unbound prefix 2Error:Execution failed for task ':chatapplication:processDebugResources'. 3> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/taichi/Library/Android/sdk/build-tools/23.0.0/aapt'' finished with non-zero exit value 1
finished with non-zero exit valueへの対策として、
File → Settings より設定画面を開き、Build, Execution, Deployment → Compiler → Java Compiler → Project bytecode version の値を空白から 1.7 に変更してからコンパイルしたのですが、結果は変わりませんでした。
Androidアプリ開発の教科書という本でやっているのですが、コードを写してもうまくいかず、英語と日本語に対応するコードは、飛ばしました。バージョンの問題でしょうか?どうぞよろしくお願いします。
今は、音声入力をつけようとしています。どうぞよろしくお願いします。
//このしたの2つのコードをついかしました。
activity_game.xml
java
1<?xml version="1.0" encoding="utf-8"?> 2<android.support.design.widget.CoordinatorLayout 3 xmlns:android="http://schemas.android.com/apk/res/android" 4 xmlns:app="http://schemas.android.com/apk/res-auto" 5 xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 6 android:layout_height="match_parent" android:fitsSystemWindows="true" 7 tools:context=".GameActivity"> 8 9 <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" 10 android:layout_width="match_parent" android:theme="@style/AppTheme.AppBarOverlay"> 11 12 <android.support.v7.widget.Toolbar android:id="@+id/toolbar" 13 android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" 14 android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> 15 16 </android.support.design.widget.AppBarLayout> 17 18 <include layout="@layout/content_game" /> 19 20 <android.support.design.widget.FloatingActionButton android:id="@+id/fab" 21 android:layout_width="wrap_content" android:layout_height="wrap_content" 22 android:layout_gravity="bottom|end" android:layout_margin="@dimen/fab_margin" 23 android:src="@android:drawable/ic_dialog_email" /> 24 25</android.support.design.widget.CoordinatorLayout> 26
content_game.xml
java
1<?xml version="1.0" encoding="utf-8"?> 2<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" 5 android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" 6 android:paddingRight="@dimen/activity_horizontal_margin" 7 android:paddingTop="@dimen/activity_vertical_margin" 8 android:paddingBottom="@dimen/activity_vertical_margin" 9 app:layout_behavior="@string/appbar_scrolling_view_behavior" 10 tools:showIn="@layout/activity_game" tools:context=".GameActivity"> 11 12 <TextView android:text="Hello World!" android:layout_width="wrap_content" 13 android:layout_height="wrap_content" /> 14</RelativeLayout> 15
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/05/25 11:10 編集
2016/05/25 13:31
2016/05/31 09:33 編集