我有以下XML父如何访问父项中的布局项目?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list_places_linearLayout" >
<LinearLayout
android:id="@+id/loadingPanel"
style="@style/GenericProgressBackground" >
<ProgressBar style="@style/GenericProgressIndicator" />
</LinearLayout>
<com.example.ListView
android:id="@+id/bottomactionbar"
style="@style/BottomActionBar" />
</LinearLayout>
的com.example.ListView是包含的AsyncTask我的自定义组件。完成此任务后,我想将父级的ProgressBar可见性设置为GONE。
所以,当在的AsyncTask子组件完成,我尝试以下方法:
LinearLayout llParent = (LinearLayout)getParent();
((LinearLayout)llParent.findViewById(R.id.loadingPanel)).setVisibility(View.GONE);
不幸的是,线llParent.findViewById(R.id.loadingPanel)为空...任何机会,我可以克服这个问题?
感谢, 费利佩
什么是空? llParent或调用findViewById()的结果? – 2012-03-18 22:06:06