![](/img/trans.png)
[英]getting text from dynamically created edittext into a button android java
[英]getting all dynamically created linearlayout android java
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);
我希望使用標簽獲得所有線性布局,但我得到了
java.lang.NullPointerException:嘗試在空對象引用上調用虛方法'android.view.View android.widget.ScrollView.findViewWithTag(java.lang.Object)'
我的所有LinearLayout(包括其所有子項)都是動態添加的
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"
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.