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

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

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

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

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Q&A

1回答

920閲覧

textviewからAlertDialogを表示させたい。

aribaba_1201

総合スコア4

Java

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

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

0グッド

0クリップ

投稿2019/12/13 06:40

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

エラーは出ていません。

javaソースコード

package com.example.kankyousettei; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.app.AlertDialog; import android.content.DialogInterface; import android.widget.*; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.setteigamen); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.option, menu); return true; } public void JPEG_click(View view) { /* AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("ダイアログのタイトル"); builder.setMessage("ダイアログのメッセージ"); AlertDialog dialog = builder.create(); dialog.show(); */ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("ダイアログのタイトル"); builder.setMessage("ダイアログのメッセージ"); builder.setPositiveButton("YES", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub TextView textView2 = (TextView) findViewById(R.id.textView2); textView2.setText("YESボタンが押されました。"); } }); builder.setNegativeButton("NO", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub TextView textView2 = (TextView) findViewById(R.id.textView2); textView2.setText("NOボタンが押されました。"); } }); builder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub TextView textView2 = (TextView) findViewById(R.id.textView2); textView2.setText("Cancelボタンが押されました。"); } }); AlertDialog dialog = builder.create(); dialog.show(); } }

XMLソースコード

<TextView android:id="@+id/JPEG" android:layout_width="139dp" android:layout_height="42dp" android:layout_below="@+id/保存設定" android:layout_marginStart="122dp" android:layout_marginLeft="122dp" android:layout_marginTop="39dp" android:layout_toEndOf="@+id/画像サイズ" android:layout_toRightOf="@+id/画像サイズ" android:clickable="true" android:onClick="onkeishikitogashitsu" android:text="@string/jpeg" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.921" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.333" android:focusable="true" tools:ignore="OnClick" />

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

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

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

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

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

退会済みユーザー

退会済みユーザー

2019/12/13 09:54

> textviewからAlertDialogを表示させたい。 というよく分からない一文だけで済まさないで、何を実装したくて、何ができないから何を聞きたいのかちゃんと書いてください。
guest

回答1

0

textViewをクリックしたときであればonClickにJPEG_clickを指定すれば良いのではないでしょうか。

投稿2021/01/22 13:54

razuma

総合スコア1313

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問