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);
我想使用标签设置为全部线性布局但是我得到
. lang。NullPointerException:尝试在空对象引用上调用虚拟方法'android.view.View android.widget.ScrollView.findViewWithTag(java.lang.Object)'
我所有的LinearLayout,包括它所有的子layout都是动态添加的
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>
ScrollView
要么没有在XML中定义,要么您的<ScrollView />
没有id layout_question_content
。检查你是否设置了android:id="@+id/layout_question_content"