質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

Q&A

解決済

1回答

524閲覧

Android Studio ボタンを押しても実行されない。

star_moca

総合スコア2

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Android Studio

Android Studioは、 Google社によって開発された、 Androidのネイティブアプリケーション開発に特化した統合開発ツールです。

0グッド

0クリップ

投稿2023/02/03 18:01

編集2023/02/04 20:22

実現したいこと

7つのボタンがあり、それらをクリックすると各ページに遷移するというプログラムを作成したい。

前提

ここに質問の内容を詳しく書いてください。

課題の一環でAndroid Studioを用いてアプリケーションの作成を行っています。

発生している問題・エラーメッセージ

一番上のbutton20を押したときは遷移するのですが、それ以外のボタンを押したときはアプリが落ちてしまいます。何が原因なのでしょうか。
ログキャットの内容

2023-02-04 03:32:20.508 13666-13710/es.exsample E/eglCodecCommon: GoldfishAddressSpaceHostMemoryAllocator: ioctl_ping failed for device_type=5, ret=-1 2023-02-04 03:32:54.311 13666-13666/es.exsample E/AndroidRuntime: FATAL EXCEPTION: main Process: es.exsample, PID: 13666 android.content.ActivityNotFoundException: Unable to find explicit activity class {es.exsample/es.exsample.Calendar_Mon}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2005) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673) at android.app.Activity.startActivityForResult(Activity.java:4586) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:705) at android.app.Activity.startActivityForResult(Activity.java:4544) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:686) at android.app.Activity.startActivity(Activity.java:4905) at android.app.Activity.startActivity(Activity.java:4873) at es.exsample.ExSample.onClick(ExSample.java:60) at es.exsample.ExSample$$ExternalSyntheticLambda0.onClick(Unknown Source:2) at android.view.View.performClick(View.java:6597) at android.view.View.performClickInternal(View.java:6574) at android.view.View.access$3100(View.java:778) at android.view.View$PerformClick.run(View.java:25885) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

該当のソースコード

言語:java

ExSample.java

1package es.exsample; 2 3import android.content.Intent; 4import android.view.View; 5import android.widget.TabHost; 6import android.widget.TabHost.TabSpec; 7import android.os.Bundle; 8 9import androidx.appcompat.app.AppCompatActivity; 10 11public class ExSample extends AppCompatActivity implements View.OnClickListener{ 12 @Override 13 protected void onCreate(Bundle savedInstanceState) { 14 super.onCreate(savedInstanceState); 15 setContentView(R.layout.activity_tabexsample); 16 17 TabHost th = (TabHost)findViewById(android.R.id.tabhost); //TabHostオブジェクト取得 18 th.setup(); //TabHostのセットアップ 19 20 TabSpec tab1 = th.newTabSpec("tab1"); //tab1のセットアップ 21 tab1.setIndicator("カレンダー"); //タブ名の設定 22 tab1.setContent(R.id.tab1); //タブに使うリニアレイアウトの指定 23 th.addTab(tab1); //タブホストにタブを追加 24 25 TabSpec tab2 = th.newTabSpec("tab2"); //tab2のセットアップ 26 tab2.setIndicator("給与"); 27 tab2.setContent(R.id.tab2); 28 th.addTab(tab2); 29 30 TabSpec tab3 = th.newTabSpec("tab3"); //tab3のセットアップ 31 tab3.setIndicator("設定"); 32 tab3.setContent(R.id.tab3); 33 th.addTab(tab3); 34 35 th.setCurrentTab(0); //最初のタブをtab1に設定 36 37 //これ以降に、各ビューに対する処理を記述する 38 findViewById(R.id.button20).setOnClickListener(this::onClick); 39 findViewById(R.id.button21).setOnClickListener(this::onClick); 40 findViewById(R.id.button22).setOnClickListener(this); 41 findViewById(R.id.button23).setOnClickListener(this); 42 findViewById(R.id.button24).setOnClickListener(this); 43 findViewById(R.id.button25).setOnClickListener(this); 44 findViewById(R.id.button26).setOnClickListener(this); 45 //ボタンがクリックされた時の処理を追加 46 } 47 48 @Override 49 public void onPointerCaptureChanged(boolean hasCapture) { 50 super.onPointerCaptureChanged(hasCapture); 51 } 52 53 @Override 54 public void onClick(View v) { 55 if(v.getId() == R.id.button20) { 56 Intent intent = new Intent(ExSample.this, Calendar_Sun.class); 57 startActivity(intent); 58 } else if (v.getId() == R.id.button21) { 59 Intent intent = new Intent(ExSample.this, Calendar_Mon.class); 60 startActivity(intent); 61 } else if (v.getId() == R.id.button22) { 62 Intent intent = new Intent(ExSample.this, Calendar_Tue.class); 63 startActivity(intent); 64 } else if (v.getId() == R.id.button23) { 65 Intent intent = new Intent(ExSample.this, Calendar_Wed.class); 66 startActivity(intent); 67 } else if (v.getId() == R.id.button24) { 68 Intent intent = new Intent(ExSample.this, Calendar_Thu.class); 69 startActivity(intent); 70 } else if (v.getId() == R.id.button25) { 71 Intent intent = new Intent(ExSample.this, Calendar_Fri.class); 72 startActivity(intent); 73 } else if (v.getId() == R.id.button26) { 74 Intent intent = new Intent(ExSample.this, Calendar_Sat.class); 75 startActivity(intent); 76 } 77 } 78}

activity_tabexsample.xml

1<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:paddingBottom="@dimen/activity_vertical_margin" 6 android:paddingLeft="@dimen/activity_horizontal_margin" 7 android:paddingRight="@dimen/activity_horizontal_margin" 8 android:paddingTop="@dimen/activity_vertical_margin" 9 tools:context="." > 10 11 12 <TabHost 13 android:id="@android:id/tabhost" 14 android:layout_width="match_parent" 15 android:layout_height="match_parent" 16 android:layout_alignParentLeft="true" 17 android:layout_alignParentTop="true" > 18 19 <LinearLayout 20 android:layout_width="match_parent" 21 android:layout_height="match_parent" 22 android:orientation="vertical" > 23 24 <TabWidget 25 android:id="@android:id/tabs" 26 android:layout_width="match_parent" 27 android:layout_height="wrap_content"></TabWidget> 28 29 <FrameLayout 30 android:id="@android:id/tabcontent" 31 android:layout_width="match_parent" 32 android:layout_height="match_parent" 33 android:orientation="vertical"> 34 35 <LinearLayout 36 android:id="@+id/tab1" 37 android:layout_width="match_parent" 38 android:layout_height="match_parent" 39 android:orientation="vertical"> 40 41 <CalendarView 42 android:id="@+id/calendarView2" 43 android:layout_width="match_parent" 44 android:layout_height="301dp" /> 45 46 <Button 47 android:id="@+id/button20" 48 android:layout_width="match_parent" 49 android:layout_height="wrap_content" 50 android:text="日曜日" /> 51 52 <Button 53 android:id="@+id/button21" 54 android:layout_width="match_parent" 55 android:layout_height="wrap_content" 56 android:text="月曜日" /> 57 58 <Button 59 android:id="@+id/button22" 60 android:layout_width="match_parent" 61 android:layout_height="wrap_content" 62 android:text="火曜日" /> 63 64 <Button 65 android:id="@+id/button23" 66 android:layout_width="match_parent" 67 android:layout_height="wrap_content" 68 android:text="水曜日" /> 69 70 <Button 71 android:id="@+id/button24" 72 android:layout_width="match_parent" 73 android:layout_height="wrap_content" 74 android:text="木曜日" /> 75 76 <Button 77 android:id="@+id/button25" 78 android:layout_width="match_parent" 79 android:layout_height="wrap_content" 80 android:text="金曜日" /> 81 82 <Button 83 android:id="@+id/button26" 84 android:layout_width="match_parent" 85 android:layout_height="wrap_content" 86 android:text="土曜日" /> 87 88 </LinearLayout> 89 90 </FrameLayout> 91 </LinearLayout> 92 </TabHost> 93 94</RelativeLayout>

試したこと

ここに問題に対して試したことを記載してください。

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

jimbe

2023/02/03 18:15 編集

コードはファイル毎にコードのマークダウン(「```」の行) で囲って、専用の枠に入るようにしてください。 また、 xml とだけ書かれても何の xml だか分かりません。 >アプリが落ちてしまいます 落ちた時にログキャットに出力される例外は確認されていますでしょうか。 例外がありましたら、(質問に追加編集して)ご提示ください。
star_moca

2023/02/03 18:42

追加いたしました。
jimbe

2023/02/03 19:07

有難うございます。
guest

回答1

0

ベストアンサー

Unable to find explicit activity class {es.exsample/es.exsample.Calendar_Mon}; have you declared this activity in your AndroidManifest.xml?

明示的なアクティビティ クラス {es.exsample/es.exsample.Calendar_Mon} が見つかりません。 AndroidManifest.xml でこのアクティビティを宣言しましたか?
(Google翻訳)

と言われています。
アクティビティは AndroidManifest.xml にも定義を書かなければ使えません。

投稿2023/02/03 19:11

編集2023/02/03 19:12
jimbe

総合スコア12545

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

star_moca

2023/02/04 11:22

そちらを完全に失念しておりました。 問題は解決しました。 本当にありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問