android - IllegalStateException : ScrollView can host only one direct child -
i have fragment, comprises of scrollview has single linearlayout(i have wrapped other linearlayouts this)
fragment_details.xml
<scrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".detailsactivityfragment"> <linearlayout...> </scrollview>
in detailsactivity i'm adding fragment
detailsactivity.java
detailsactivityfragment fragment = new detailsactivityfragment(); fragment.setarguments(b); getsupportfragmentmanager().begintransaction() .add(r.id.movie_details,fragment) .commit();
activity_details.xml
<fragment android:id="@+id/movie_details" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:name=".detailsactivityfragment" tools:ignore="mergerootframe"/>
but when run program following error:
java.lang.runtimeexception: unable start activity componentinfo{...}: java.lang.illegalstateexception: scrollview can host 1 direct child
i have followed threads on issue of scrollview, i'm not able solve this. please!!
use frame layout instead of fragment in activity_details bcoz fragment used when u have fixed fragment show. here u r showing ur movie detail fragment using again u r inflating fragment(another instance of movie detail fragment) in ur activity , creates problem.
Comments
Post a Comment