Android開発をしています初心者です。
検索機能を作成しています。
ScrollView内にListViewを3つ持ちたいです。
各々のLisViewに表示されるリストは1件〜3件までです。
デザインを担当している人がいるのですが
作成されたデザインに合わせて、JSONで1~3件ずつPHPからデータを取得して
別々のListViewに表示させています。
以下がUI(見ずらくて申し訳ございません)と、XMLのコードです。
text
1------------------- 2------------------- 3名前 4List1 5List2 6List3 7------------------- 8全件表示ボタン 9------------------- 10 11------------------- 12概要 13List1 14------------------- 15全件表示ボタン 16------------------- 17 18 19------------------- 20詳細 21List1 22List2 23------------------- 24全件表示ボタン 25------------------- 26
xml
1<?xml version="1.0" encoding="utf-8"?> 2 3<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 android:background="#EEEEEE" 7 android:orientation="vertical"> 8 9 <!--「〜」の検索結果--> 10 <LinearLayout 11 android:layout_width="match_parent" 12 android:layout_height="wrap_content" 13 android:paddingTop="15dp" 14 android:paddingBottom="15dp" 15 android:background="#EEEEEE" 16 android:orientation="horizontal"> 17 18 <TextView 19 android:layout_width="wrap_content" 20 android:layout_height="wrap_content" 21 android:text="「" 22 android:textColor="#515151" 23 android:textSize="17sp" /> 24 25 <TextView 26 android:id="@+id/search_result_text" 27 android:layout_width="wrap_content" 28 android:layout_height="wrap_content" 29 android:text="text" 30 android:textColor="#515151" 31 android:textSize="17sp" 32 android:textStyle="bold" /> 33 34 <TextView 35 android:layout_width="wrap_content" 36 android:layout_height="wrap_content" 37 android:text="」の検索結果" 38 android:textColor="#515151" 39 android:textSize="17sp" /> 40 41 42 </LinearLayout> 43 44 <!--スペース①--> 45 <LinearLayout 46 android:layout_width="match_parent" 47 android:layout_height="5dp" 48 android:background="#FFFFFF" /> 49 50 51<!--*********************** 名前 ********************************** --> 52 <!--名前文言--> 53 <LinearLayout 54 android:layout_width="match_parent" 55 android:layout_height="wrap_content" 56 android:background="#DBDBDB" 57 android:gravity="center_vertical" 58 android:paddingLeft="20dp" 59 android:orientation="horizontal"> 60 61 62 <TextView 63 android:layout_width="match_parent" 64 android:layout_height="wrap_content" 65 android:text="名前" 66 android:background="#DBDBDB" 67 android:textColor="#515151" 68 android:textSize="18sp"/> 69 70 71 </LinearLayout> 72 73 <!--スペース②--> 74 <LinearLayout 75 android:layout_width="match_parent" 76 android:layout_height="5dp" 77 android:background="#FFFFFF" /> 78 79 <!--名前listView--> 80 <ListView 81 android:id="@+id/list_name" 82 android:layout_width="match_parent" 83 android:layout_height="wrap_content" 84 android:paddingRight="20dp" 85 android:paddingLeft="20dp" 86 android:background="#DBDBDB"/> 87 88 <!--すべて見るボタン--> 89 <ListView 90 android:id="@+id/all_name" 91 android:layout_width="match_parent" 92 android:layout_height="wrap_content" 93 android:paddingRight="20dp" 94 android:paddingLeft="20dp" /> 95 96<!--*********************** 名前ここまで **************************** --> 97 98 <!--スペース③--> 99 <LinearLayout 100 android:layout_width="match_parent" 101 android:layout_height="5dp" 102 android:background="#FFFFFF" /> 103 104 105<!--*********************** 概要 *********************************** --> 106 107 <!--概要文言--> 108 <LinearLayout 109 android:layout_width="match_parent" 110 android:layout_height="wrap_content" 111 android:background="#DBDBDB" 112 android:gravity="center_vertical" 113 android:paddingLeft="20dp" 114 android:orientation="horizontal"> 115 116 <TextView 117 android:layout_width="match_parent" 118 android:layout_height="wrap_content" 119 android:text="概要" 120 android:background="#DBDBDB" 121 android:textColor="#515151" 122 android:textSize="18sp"/> 123 124 </LinearLayout> 125 126 127 <!--スペース④--> 128 <LinearLayout 129 android:layout_width="match_parent" 130 android:layout_height="5dp" 131 android:background="#FFFFFF" /> 132 133 134 <!--概要ListView--> 135 <ListView 136 android:id="@+id/list_gaiyo" 137 android:layout_width="match_parent" 138 android:layout_height="wrap_content" 139 android:paddingRight="20dp" 140 android:paddingLeft="20dp" 141 android:background="#DBDBDB"/> 142 143 <!--全件表示ボタン②--> 144 <ListView 145 android:id="@+id/all_gaiyo" 146 android:layout_width="match_parent" 147 android:layout_height="wrap_content" 148 android:paddingRight="20dp" 149 android:paddingLeft="20dp"/> 150 151 152<!--*********************** 概要ここまで ******************************** --> 153 154 <!--スペース⑤--> 155 <LinearLayout 156 android:layout_width="match_parent" 157 android:layout_height="5dp" 158 android:background="#FFFFFF" /> 159 160 161<!--************************** 詳細 ************************************ --> 162 <!--詳細文言--> 163 <LinearLayout 164 android:layout_width="match_parent" 165 android:layout_height="wrap_content" 166 android:background="#DBDBDB" 167 android:gravity="center_vertical" 168 android:paddingLeft="20dp" 169 android:orientation="horizontal"> 170 171 <TextView 172 android:layout_width="match_parent" 173 android:layout_height="wrap_content" 174 android:text="詳細" 175 android:background="#DBDBDB" 176 android:textColor="#515151" 177 android:textSize="18sp"/> 178 179 </LinearLayout> 180 181 182 <!--スペース⑥--> 183 <LinearLayout 184 android:layout_width="match_parent" 185 android:layout_height="5dp" 186 android:background="#FFFFFF" /> 187 188 189 <!--詳細ListView--> 190 <ListView 191 android:id="@+id/list_detail" 192 android:layout_width="match_parent" 193 android:layout_height="wrap_content" 194 android:paddingRight="20dp" 195 android:paddingLeft="20dp" 196 android:background="#DBDBDB"/> 197 198 <!--全件表示ボタン③--> 199 <ListView 200 android:id="@+id/all_detail" 201 android:layout_width="match_parent" 202 android:layout_height="wrap_content" 203 android:paddingRight="20dp" 204 android:paddingLeft="20dp"/> 205 206 207<!--************************** 詳細ここまで ******************************** --> 208 209 210</LinearLayout>
しかし、デザイン担当がぐちゃぐちゃに作っていたので
一つの画面に、3つのListViewがあり個々のListView単体でスクロールするため、
画面全体がスクロールしないです。なので、一番したにあるボタン(ListViewで作られた)が見えません。
小さい端末だと、ボタンどころか、下の詳細まで見えなくなります。
TextViewでやろうとしましたが、
Listの数は、1件〜3件と動的に変化するため、
setTextでやろうとすると、
例えば1件の場合、下にtextのない2件が表示されてしまいます。
下記の方法でやってみても、よくわからず。。。
http://blog.howtelevision.co.jp/entry/2015/03/19/115020
この記事の場合、
ListViewを継承しているclassは
新規にfileを作成したところに実装するのでしょうか?
また、これを呼び出す際は、Activityのどこで呼び出せば良いのでしょうか。
何か、情報の不足がありましたら、
追記しますので、コメント頂けますと幸いです。
文章ばかりでわかりにくく、申し訳ございません。
ご教示のほど、よろしくお願いいたします。
あなたの回答
tips
プレビュー