2017-09-04 21 views
0

私のレイアウトでは、複数のScrollViewを持つLinearLayoutを作成しました。そこにはFAQセクションがあります.Scrollviewsには、複数の展開可能なTextViewを追加しました。
2つ目のScrollViewに拡張可能なTextViewを追加すると、アクティビティがクラッシュして、設計時にレンダリングの問題が発生することがわかりました。問題は、2番目の拡張可能なTextViewをコメントアウトするレイアウトコードですそれは動作:複数の展開可能なTextViewを追加する方法

あなたは両方のScrollViewの @+id/expandable_text/ @+id/expandable_text2@+id/expand_collapse/ @+id/expand_collapse2に持って
<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_alignLeft="@+id/linkbot" 
     android:layout_alignStart="@+id/linkbot" 
     android:layout_alignRight="@+id/linkbot" 
     android:layout_alignEnd="@+id/linkbot" 
     android:layout_above="@+id/linkbot" 
     android:layout_below="@+id/textView"> 

     <ScrollView 
      android:id="@+id/faq1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_above="@+id/faq2" 
      > 

      <com.ms.square.android.expandabletextview.ExpandableTextView 
       android:id="@+id/expandable_text_view1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 


       app:animDuration="200" 
       app:maxCollapsedLines="1" 

       > 

       <LinearLayout 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"> 

        <TextView 
         android:id="@+id/expandable_text" 
         android:layout_width="wrap_content" 
         android:layout_height="match_parent" 



         /> 

        <ImageButton 

         android:id="@+id/expand_collapse" 
         android:layout_width="wrap_content" 
         android:layout_gravity="bottom|end" 
         android:background="@android:color/transparent" 
         android:padding="14dp" 
         android:layout_height="match_parent" /> 

       </LinearLayout> 

      </com.ms.square.android.expandabletextview.ExpandableTextView> 


     </ScrollView> 
     <ScrollView 
      android:id="@+id/faq2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      > 
      <com.ms.square.android.expandabletextview.ExpandableTextView 
       android:id="@+id/expandable_text_view2" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 


       app:animDuration="200" 
       app:maxCollapsedLines="1" 

       > 

       <LinearLayout 

        android:layout_width="match_parent" 
        android:layout_height="match_parent"> 

        <TextView 
         android:id="@+id/expandable_text2" 
         android:layout_width="wrap_content" 
         android:layout_height="match_parent" 
         /> 

        <ImageButton 

         android:id="@+id/expand_collapse2" 
         android:layout_width="wrap_content" 
         android:layout_gravity="bottom|end" 
         android:background="@android:color/transparent" 
         android:padding="14dp" 
         android:layout_height="wrap_content" /> 

       </LinearLayout> 

      </com.ms.square.android.expandabletextview.ExpandableTextView> 




     </ScrollView> 
    </LinearLayout> 

答えて

0

。それぞれ@id/expandable_text@id/expand_collapseに置き換えても問題ありません。

あなたはExpandableTextViewライブラリdocumentationに気付いた場合、それはExpandableTextView内部のTextViewとのImageButton IDが@id/expandable_text@id/expand_collapseに設定されなければならないことを述べています。

+0

、高速応答のおかげで、私はあなたがこのよう 'expandableTextView1 =(ExpandableTextView)findViewById(R.id.expandable_text_view1)それを行うことができます –

+0

申し訳ありませんが推測します。 'setText'メソッドを直接呼び出します。 'expandableTextView1.setText(" your text ")' –

+0

フォーマットするのを忘れて、今OK –

関連する問題