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

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

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

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

Android Studio

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

Q&A

1回答

1286閲覧

マップアプリ作成に関して

退会済みユーザー

退会済みユーザー

総合スコア0

Java

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

Android Studio

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

0グッド

0クリップ

投稿2019/06/01 07:50

##自分は、金沢観光アプリをAndroid Studioでjava言語を利用して作ろうと思ってます。
##完成形は、
######1 金沢へようこそ!左にスワイプしてください!と表記させる

######2 左にスワイプするとボタンが二つ生成され、どちらのボタンを押したかによって処理を変える([観光地リストへ]というボタンを押すと観光地の選択肢がラジオボタンで与えられる、[トップページへ]というボタンを押すと1に戻る。)

######3 観光地の選択肢のラジオボタンを押すと、地図が表示され、現在地、目的地の場所をピンで記す

######4 5秒後音声案内を開始する。

######5 目的地に着いたら、音声案内を終了する。

##といったプログラムを作りたいのですが、2の(「観光地リストへ」というボタンを押すと観光地の選択肢がラジオボタンで与えられる)というところがうまくできません。どなたか原因を教えていただけると助かります。今現在コードは以下のようになってます。

package es.exsample;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.TranslateAnimation;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.ViewFlipper;

public class ExSample extends AppCompatActivity {
static final int num = 100;
ViewFlipper vf;
TextView tv1,tv2;
Button bt1,bt2; //ボタン生成
RadioButton rb[] = new RadioButton[4];
RadioGroup rg;

ListView lv; LinearLayout[] ll = new LinearLayout[3]; float x; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); LinearLayout llp = new LinearLayout(this); setContentView(llp); vf = new ViewFlipper(this); tv1 = new TextView(this); tv1.setTextSize(20); tv1.setText("金沢へようこそ!"); tv2 = new TextView(this); tv2.setTextSize(20); tv2.setText("左にフリップしてください"); bt1 = new Button(this); bt1.setText("観光地リストへ"); bt2 = new Button(this); bt2.setText("トップページへ"); for(int i=0; i<rb.length; i++) //ラジオボタンの各要素の生成 rb[i] = new RadioButton(this); rb[0].setText("近江町市場"); //ラジオボタンのテキストの設定 rb[1].setText("東茶屋街"); rb[2].setText("武家屋敷"); rb[3].setText("忍者寺"); rg = new RadioGroup(this); //ラジオグループの生成 for(int i=0; i<rb.length; i++) //ラジオグループにラジオボタンを登録 rg.addView(rb[i]); lv = new ListView(this); ArrayAdapter<String> ad = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, str); lv.setAdapter(ad); ll[0] = new LinearLayout(this); ll[0].addView(tv1); ll[0].addView(tv2); vf.addView(ll[0]); ll[1] = new LinearLayout(this); ll[1].addView(bt1); ll[1].addView(bt2); vf.addView(ll[1]); ll[2] = new LinearLayout(this); ll[2].addView(lv); vf.addView(ll[2]); llp.addView(vf); setContentView(llp); llp.setOnTouchListener(new SampleTouchListener()); bt1.setOnClickListener(new ExSampleClickListener()); //ボタンを押した際のフリップアニメーションの設定 bt2.setOnClickListener(new ExSampleClickListener()); for(int i=0; i<rb.length; i++) rb[i].setOnClickListener(new ExSample.ExSampleClickListener()); //ラジオボタンクリック時のリスナー登録 } class SampleTouchListener implements OnTouchListener{ public boolean onTouch(View v, MotionEvent e){ if(e.getAction() == MotionEvent.ACTION_DOWN){ x = e.getX(); } else if(e.getAction() == MotionEvent.ACTION_UP){ if(x-20 > e.getX()){ TranslateAnimation inanim = new TranslateAnimation(tv1.getWidth(), 0, 0, 0); inanim.setDuration(500); TranslateAnimation outanim = new TranslateAnimation(0,-tv1.getWidth(), 0, 0); outanim.setDuration(500); vf.setInAnimation(inanim); vf.setOutAnimation(outanim); vf.showNext(); } else if(x+20 < e.getX()){ TranslateAnimation inanim = new TranslateAnimation(-tv1.getWidth(), 0, 0, 0); inanim.setDuration(500); TranslateAnimation outanim = new TranslateAnimation(0,tv1.getWidth(), 0, 0); outanim.setDuration(500); vf.setInAnimation(inanim); vf.setOutAnimation(outanim); vf.showPrevious(); } } return true; } } class ExSampleClickListener implements View.OnClickListener { //ボタンを押した際のフリップアニメーション処理 public void onClick(View v){ if(v==bt1) { TranslateAnimation inanim = new TranslateAnimation(tv1.getWidth(), 0, 0, 0); inanim.setDuration(500); TranslateAnimation outanim = new TranslateAnimation(0, -tv1.getWidth(), 0, 0); outanim.setDuration(500); vf.setInAnimation(inanim); vf.setOutAnimation(outanim); vf.showNext(); } else if(v==bt2) { TranslateAnimation inanim = new TranslateAnimation(-tv1.getWidth(), 0, 0, 0); inanim.setDuration(500); TranslateAnimation outanim = new TranslateAnimation(0, tv1.getWidth(), 0, 0); outanim.setDuration(500); vf.setInAnimation(inanim); vf.setOutAnimation(outanim); vf.showPrevious(); } } }

}

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

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

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

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

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

jimbe

2019/06/01 10:03

コードは「```」の行で上下を挟むと専用の枠が付いてインデントが再現されますので, そのように修正をして頂けますか. 入力欄の上にある "<code>" というボタンで雛形が出ますので.
guest

回答1

0

入力間違いでした. すいません

投稿2019/06/01 10:03

編集2019/06/01 10:04
jimbe

総合スコア12648

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問