我想扩展现有的Activity更改其布局,我正在尝试这样做:
public class NewActivity extends ParentActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_layout);
...
}
但它不起作用;旧的布局出现了! 另一方面,如果我这样做:
public class NewActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.new_layout);
...
}
那么它有效......为什么?
ParentActivity的onCreate():
@Override
public void onCreate(Bundle savedInstanceState)
{
setTitle(R.string.title_home);
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
....
}