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

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

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

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

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

Q&A

解決済

1回答

495閲覧

二つのListViewのスクロールを同期させたい

moyashikun

総合スコア11

Android Studio

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

Kotlin

Kotlinは、ジェットブレインズ社のアンドリー・ブレスラフ、ドミトリー・ジェメロフが開発した、 静的型付けのオブジェクト指向プログラミング言語です。

0グッド

0クリップ

投稿2020/07/29 05:20

前提・実現したいこと

二つのリストのスクロールを同期させたい

該当のソースコード

Kotlin

1class ListActivity : AppCompatActivity() { 2 override fun onCreate(savedInstanceState: Bundle?) { 3 super.onCreate(savedInstanceState) 4 setContentView(R.layout.activity_list_actvity) 5 val listA = arrayOf("aaaa","bbbb","cccc","bbbb","cccc","bbbb","cccc","bbbb","cccc","bbbb","cccc","bbbb","cccc","bbbb","cccc","bbbb","cccc","bbbb","cccc","bbbb","cccc") 6 val listB = arrayOf("1111","2222","3333","2222","3333","2222","3333","2222","3333","2222","3333","2222","3333","2222","3333","2222","3333","2222","3333","2222","3333") 7 val arrayAdapterListA = ArrayAdapter(this,android.R.layout.simple_list_item_1,listA) 8 val arrayAdapterListB = ArrayAdapter(this,android.R.layout.simple_list_item_1,listB) 9 listA.adapter = arrayAdapterListA 10 listB.adapter = arrayAdapterListB 11 } 12}

xml

1<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <LinearLayout 8 android:layout_width="match_parent" 9 android:layout_height="wrap_content" 10 android:orientation="horizontal" > 11 12 <TextView 13 android:id="@+id/title1" 14 android:layout_width="match_parent" 15 android:layout_height="wrap_content" 16 android:layout_weight="1" 17 android:gravity="center" 18 tools:text="listA" /> 19 20 <TextView 21 android:id="@+id/title2" 22 android:layout_width="match_parent" 23 android:layout_height="wrap_content" 24 android:layout_weight="1" 25 android:gravity="center" 26 tools:text="@listB" /> 27 </LinearLayout> 28 29 <LinearLayout 30 android:layout_width="match_parent" 31 android:layout_height="match_parent" 32 android:orientation="horizontal"> 33 34 <ListView 35 android:id="@+id/listA" 36 android:layout_width="match_parent" 37 android:layout_height="wrap_content" 38 android:layout_weight="1"> 39 40 </ListView> 41 42 <ListView 43 android:id="@+id/listB" 44 android:layout_width="match_parent" 45 android:layout_height="wrap_content" 46 android:layout_weight="1" /> 47 48 </LinearLayout> 49 50</LinearLayout>

試したこと

どのようなアプローチでスクロールを同期させればよいのでしょうか、ご教示お願いします

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

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

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

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

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

guest

回答1

0

自己解決

この方法での実装をあきらめました

投稿2020/08/05 05:13

moyashikun

総合スコア11

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問