如果想通过调用findViewById()方法获取到相应的控件,必须要求当前Activity的layout通过setContentView. 如果你通过其他方法添加了一个layout,如需获取这个layout中的View对象,首先需inflate这个layout,然后在该layout上调用findViewById().
View v = inflater.inflate(id_number_of_layout);
View innerView = v.findViewById(id_number_of_view_inside_v);