ScrollView sv = (ScrollView) v.findViewById(R.id.layout_question_content);
LinearLayout layout_questions = (LinearLayout) sv.findViewWithTag("layout_questions");
int childcount = layout_questions.getChildCount();
System.out.println("LinearLayout " + childcount);
I want to get All Linear Layout using tag but I get
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.widget.ScrollView.findViewWithTag(java.lang.Object)' on a null object reference
All my LinearLayout including all its child are dynamically added
XML
<ScrollView
android:id="@+id/layout_question_content"
android:clickable="true"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_marginBottom="50px"
android:layout_height="fill_parent">
</ScrollView>
The ScrollView
is either not defined in your XML or your <ScrollView />
does not have the id layout_question_content
. Check that you have android:id="@+id/layout_question_content"
set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.