的子类空我有一个SettingsActivity是PreferenceActivity的子类在我的图书馆项目在返回的LinearLayout是PreferenceActivity
的onCreate方法看起来像这样
addPreferencesFromResource(R.xml.preferences);
setContentView(R.layout.main);
的preference.xml文件有结构是怎样的元素PreferenceScreen - > PreferenceCategory - >首选项 我主要的main.xml貌似这个
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!--Listview will be replaced by preferences -->
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
上面的类SettingsActivity是另一个项目的子类,看起来像这样
public class SettingsActivityFree extends SettingsActivity
{
private AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//...
// layout returned will be null ..
LinearLayout layout = (LinearLayout)findViewById(R.layout.main);
// Add the adView to it
layout.addView(adView);
}
问题是我想从父类得到的LinearLayout,这样我可以在里面加我的东西,但由于某些原因,它返回空,我有LinearLyout在SettingsActivity类的原因是因为我希望把一些广告等在喜好的顶部,并没有把广告特定代码在库项目
请告知,如果我在这里失去了一些东西,
谢谢
谢谢我的工作,是我的错误深夜工作:) – Ahmed 2012-07-06 05:48:56