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

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

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

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

Android

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

Android Studio

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

Q&A

解決済

1回答

687閲覧

AndroidでPopupWindowにListviewを使いたい

tanuki_

総合スコア31

Java

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

Android

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

Android Studio

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

0グッド

0クリップ

投稿2019/12/05 02:37

編集2019/12/05 04:26

前提・実現したいこと

PopupWindowにてListViewを使いたいと思っています。

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

実行した所ListViewは表示されるのですがテキストが表示されません
どこがおかしいのでしょうか?
追記
2019/12/05 13:23
行をタップするとテキストが表示されました。
PopupWindowが表示される際にタップしなくても表示されるようにしたいです。
よろしくお願い致します。

該当のソースコード

PopupWindowのレイアウト

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:padding="8dp"> <!-- ヘッダー表示部 --> <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="40dp" android:layout_gravity="top" android:background="@color/yellow"> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="1" android:gravity="top|center" android:text="<届け先・グルーピングNo.>" android:textColor="#000000" android:textSize="32sp" android:textStyle="bold" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="40dp" android:layout_gravity="top" android:background="@color/yellow"> </LinearLayout> <!-- メイン表示部(タイトル) --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/title1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="@dimen/dp_s" android:layout_marginBottom="@dimen/dp_s" android:layout_weight="1" android:layout_gravity="center" android:background="@color/title" android:gravity="center" android:padding="@dimen/dp_m" android:text="\nタイトル1\n" android:textColor="#000000" android:textSize="@dimen/sp_s" /> <TextView android:id="@+id/title2" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="@dimen/dp_s" android:layout_marginBottom="@dimen/dp_s" android:layout_weight="1" android:layout_gravity="center" android:background="@color/title" android:gravity="center" android:padding="@dimen/dp_m" android:text="\nタイトル2.\n" android:textColor="#000000" android:textSize="@dimen/sp_s" /> <TextView android:id="@+id/title3" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginRight="@dimen/dp_s" android:layout_marginBottom="@dimen/dp_s" android:layout_weight="1" android:layout_gravity="center" android:background="@color/title" android:gravity="center" android:padding="@dimen/dp_m" android:text="\nタイトル3\n" android:textColor="#000000" android:textSize="@dimen/sp_s" /> </LinearLayout> <!-- メイン表示部(明細) --> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="5dp" android:background="@color/white" android:layout_weight="1" /> <!-- ボタン表示部 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="top|center" android:visibility="visible" android:background="@color/yellow"> <Button android:id="@+id/close_button" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="top|center" android:textSize="28sp" android:text="閉じる" /> </LinearLayout> </LinearLayout>

Javaのソースコード

public void makeDeliveredtoData(int detailNo, List<Data> dataList, View v,Resources res) { int gdetailNo = detailNo; ArrayList<DeliveredtoData> deloveredtoList = new ArrayList<DeliveredtoData>(); DeliveredtoData data; Data work; Data target; for (int i = 0; i <= dataList.size() - 1; i++) { target = new Data(); target = dataList.get(i); if(detailNo == target.getShuyakuFlg()){ data = new DeliveredtoData(); work = dataList.get(i); data.setSeihin(work.getSeihin()); data.setDetailNo(work.getDetailNo()); data.setGroupNo(work.getGroupNo()); data.setDestinationName(work.getDestinationName()); data.setLoke(work.getLoke()); deloveredtoList.add(data); } } final ArrayList rows = new ArrayList(); for (int i = 0; i <= deloveredtoList.size() - 1; i++) { DeliveredtoData deloveredtoData = new DeliveredtoData(); deloveredtoData = deloveredtoList.get(i); rows.add("あああ"); } mPopupWindow = new PopupWindow(con); //1 一般的な方法 LayoutInflater inflater = LayoutInflater.from(con); // レイアウト設定 View popupView = inflater.inflate(R.layout.popup_layout, null); popupView.findViewById(R.id.close_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mPopupWindow.isShowing()) { mPopupWindow.dismiss(); } } }); ListView listView = new ListView(con); listView = (ListView)popupView.findViewById(R.id.listView); mPopupWindow.setContentView(popupView); // 背景設定 mPopupWindow.setBackgroundDrawable(res.getDrawable(R.drawable.popup_background)); // タップ時に他のViewでキャッチされないための設定 mPopupWindow.setOutsideTouchable(true); mPopupWindow.setFocusable(true); // 表示サイズの設定 今回は幅800dp float width = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 800, res.getDisplayMetrics()); mPopupWindow.setWindowLayoutMode((int) width, WindowManager.LayoutParams.WRAP_CONTENT); mPopupWindow.setWidth((int) width); mPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); //ArrayAdapter<String> adapter = new ArrayAdapter<String>(con, android.R.layout.simple_list_item_1); ArrayAdapter adapter = new ArrayAdapter(con, android.R.layout.simple_expandable_list_item_1, rows); //Adapterの指定 listView.setAdapter(adapter); // 画面中央に表示 mPopupWindow.showAtLocation(v, Gravity.CENTER, 0, 0); }

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

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

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

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

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

y_waiwai

2019/12/05 02:55

このままではコードが読みづらいので、質問を編集し、<code>ボタンを押し、出てくる’’’の枠の中にコードを貼り付けてください
tanuki_

2019/12/05 04:07

ご指摘ありがとうございます。 コードボタンを使い編集致しました。
guest

回答1

0

自己解決

解決致しましたのでご報告させて頂きます。
ListViewのテキストカラーがキモでした。
カスタマイズすれば別ですが、テキストカラーがホワイトにも関わらず
背景色にホワイトを指定しておりました。。
初歩的なミスです。
お騒がせしまして大変申し訳ありませんでした。

投稿2019/12/05 07:30

tanuki_

総合スコア31

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問