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

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

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

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

Android

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

Android Studio

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

Q&A

解決済

1回答

232閲覧

遷移先のActivityが空白になってしまう

syyyow

総合スコア28

Java

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

Android

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

Android Studio

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

0グッド

0クリップ

投稿2018/06/16 13:31

編集2018/06/16 23:52

遷移をコードを作成したのですが
遷移先のViewが白紙になってしまいます。
原因がわかりませんので
コードを解読しわかる方お願い致します。

java

1 2Product.java 3import android.content.Intent; 4import android.os.Bundle; 5import android.support.annotation.NonNull; 6import android.support.annotation.Nullable; 7import android.support.v4.app.Fragment; 8import android.view.LayoutInflater; 9import android.view.View; 10import android.view.ViewGroup; 11import android.widget.Button; 12import android.widget.ImageButton; 13import android.widget.TextView; 14 15public class Product extends Fragment { 16 17 @Nullable 18 @Override 19 public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 20 View view = inflater.inflate(R.layout.product, container, false); 21 ImageButton imageButton = (ImageButton) view.findViewById(R.id.imageButton); // view経由でimageButtonを探す 22 imageButton.setOnClickListener(new View.OnClickListener() { 23 24 25 public void onClick(View v) { 26 Intent i = new Intent(v.getContext(), Product_box.class); 27 startActivity(i); 28 } 29 }); 30 return view; 31 } 32}

java

1 2Product_box.java 3 4import android.content.Intent; 5import android.support.v7.app.AppCompatActivity; 6import android.os.Bundle; 7import android.widget.TextView; 8 9public class Product_box extends AppCompatActivity { 10 11 @Override 12 protected void onCreate(Bundle savedInstanceState) { 13 super.onCreate(savedInstanceState); 14 15 setContentView(R.layout.activity_product_box); 16 17 Intent intent = getIntent(); 18 TextView textView = (TextView)this.findViewById(R.id.imageButton); 19 20 } 21} 22 23

java

1 2activity_product_box.xml 3 4<?xml version="1.0" encoding="utf-8"?> 5<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 6 xmlns:app="http://schemas.android.com/apk/res-auto" 7 android:layout_width="match_parent" 8 android:layout_height="match_parent" 9 android:orientation="vertical"> 10 11 <ScrollView 12 android:layout_width="match_parent" 13 android:layout_weight="1"> 14 15 <LinearLayout 16 android:layout_width="match_parent" 17 android:layout_height="wrap_content" 18 android:orientation="vertical"> 19 20 <FrameLayout 21 android:layout_width="match_parent" 22 android:layout_height="wrap_content" 23 android:layout_weight="1"> 24 25 <ImageView 26 android:id="@+id/imageView" 27 android:layout_width="match_parent" 28 android:layout_height="260dp" 29 android:layout_weight="1" 30 app:srcCompat="@drawable/box" /> 31 32 </FrameLayout> 33 34 35 <FrameLayout 36 android:layout_width="match_parent" 37 android:layout_height="match_parent" 38 android:layout_weight="1"> 39 40 <TextView 41 android:id="@+id/textView1" 42 android:layout_width="match_parent" 43 android:layout_height="34dp" 44 android:layout_weight="1" 45 android:text="タイトル" 46 android:textSize="24sp" /> 47 48 <android.support.design.widget.FloatingActionButton 49 android:id="@+id/floatingActionButton2" 50 android:layout_width="wrap_content" 51 android:layout_height="wrap_content" 52 android:layout_gravity="right" 53 android:clickable="true" 54 app:srcCompat="@android:drawable/btn_star_big_on" /> 55 56 </FrameLayout> 57 58 59 <FrameLayout 60 android:layout_width="match_parent" 61 android:layout_height="match_parent" 62 android:layout_weight="1"> 63 64 <TextView 65 android:id="@+id/textView6" 66 android:layout_width="wrap_content" 67 android:layout_height="wrap_content" 68 android:text="〜〜〜 69〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜〜" /> 70 71 </FrameLayout> 72 73 74 <FrameLayout 75 android:layout_width="match_parent" 76 android:layout_height="match_parent" 77 android:layout_weight="1"> 78 79 <android.support.design.widget.FloatingActionButton 80 android:id="@+id/floatingActionButton" 81 android:layout_width="wrap_content" 82 android:layout_height="wrap_content" 83 android:clickable="true" 84 app:srcCompat="@drawable/ic_cart_black_24dp" /> 85 86 <Button 87 android:id="@+id/button2" 88 android:layout_width="wrap_content" 89 android:layout_height="match_parent" 90 android:layout_gravity="right" 91 android:text="購入画面" 92 android:textStyle="bold" /> 93 </FrameLayout> 94 95 96 <FrameLayout 97 android:layout_width="match_parent" 98 android:layout_height="match_parent" 99 android:layout_weight="1"> 100 101 </FrameLayout> 102 </LinearLayout> 103 </ScrollView> 104 105</LinearLayout> 106

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

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

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

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

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

keicha_hrs

2018/06/16 16:05

activity_product_box.xmlの内容が提示されなければわかりません。
syyyow

2018/06/16 23:53

失礼いたしました。追記させていただきました。宜しくお願いたします。
guest

回答1

0

ベストアンサー

ScrollViewタグにandroid:layout_heightがありません。layout_heightは指定必須なので、これではまずビルドが通らないのでは?後は、FloatingActionButtonを使っていますから、

gradle

1dependencies { 2 // 前後は略 3 implementation 'com.android.support:design:27.1.1' 4}

の追記も必要でしょう。(これも行わなければビルドが通らないと思いますが)

それだけすれば、一応下図のように表示はされるようです(画像は適当に選んだが)。

投稿2018/06/17 07:28

keicha_hrs

総合スコア6766

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

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

syyyow

2018/06/17 08:21

ようやく遷移ができました。 初歩的なところにも関わらず 細かなアドバイスありがとうございます!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.50%

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

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

質問する

関連した質問