6

垂直リストビュー内に水平リストビューを作成する必要があります。両方のリストビューには任意の数の要素を含めることができ、両方ともスクロール可能である必要があります。

Androidはリストビュー階層をサポートしていないことを読んだので、これをどのように達成しますか。

ありがとう !

カスタムUI

4

4 に答える 4

3

これを実現するには、次のことを行う必要があります。

  1. 単一のLinearLayoutを持つ垂直ScrollViewを作成します。
  2. 次に、以下の例に示すように、このLinearlayout内に水平リストビューを作成します。

したがって、これにより、画面を垂直方向にスクロールしたり、各ListViewを水平方向にスクロールしたりできます。

たとえば。

<ScrollView>  

  <LinearLayout.....  //this a vertically oriented layout
  >  
     <ListView/>  
     .
     .//This listViews Are Horizontal
     .
     <ListView>
  </Linearlayout>
</ScrollView>    

編集: LinearLayoutに動的にListViewを追加します。

LinearLayout ll=(LinearLayout)findViewById(R.id.id_given_in_the_XML_file);  
ListView lv=new ListView(Activityname.this);  
.
.
.
Do All ListView Processing Here
.
.
.
lv.setAdapater(adapter);  

ll.addView(lv);
于 2012-07-30T12:30:03.380 に答える
1

ListViewを使用して垂直方向にスクロールし、ScrollView内のLinearLayoutを使用して水平方向のスクロールを行うことをお勧めします。

ListView-アイテム1:-Horizo​​ntalScrollView-LinearLayout(orientation:horizo​​ntal)

この回答も確認してください-https://stackoverflow.com/questions/5398449/how-can-i-create-a-pulse-like-ui-for-an-android-application

于 2012-07-30T12:31:00.123 に答える
0
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/ll"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical" >

 <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Accounts" />
<ListView
    android:id="@+id/Accounts"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical" />
<View
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#FF4500" />
<TextView
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Contacts" />
<ListView
    android:id="@+id/con_listView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical" />
</LinearLayout>
于 2012-07-30T12:30:38.460 に答える
0

それは不可能ですが、私が使って私のために働いたトリックを1つ行うことができます。これを使用して、外部リストビューのスクロールメソッドを停止(中断)できます:)

水平リストビューHV内にリストビューLVがあるとすると、リストビューのタッチメソッドで次のように記述する必要があります-

lv.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View arg0, MotionEvent arg1) {

                if(arg1.getAction() == MotionEvent.ACTION_DOWN || arg1.getAction() == MotionEvent.ACTION_MOVE)
                {
                HV.requestDisallowInterceptTouchEvent(true);

                }
                return false;
            }
        });
于 2012-07-30T12:34:40.553 に答える