该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

public class MainActivity extends Activity {

private MyLinearLayout layoutOne;

private MyLinearLayout layoutTwo;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

layoutOne = (MyLinearLayout) super.findViewById(R.id.myView1);

LayoutInflater flater = LayoutInflater.from(this);

final LinearLayout layout_1 = (LinearLayout) flater.inflate(R.layout.view1, null);

layoutOne.setAdater(new MyAdapterOne() {

@Override

public View addView() {

return layout_1;

}

});

//这个view无法显示,是什么原因?

layoutTwo = (MyLinearLayout) layout_1.findViewById(R.id.myView2);

final LinearLayout layout_2 = (LinearLayout) flater.inflate(R.layout.view2, null);

layoutTwo.setAdater(new MyAdapterOne() {

@Override

public View addView() {

return layout_2;

}

});

}

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐