0
Я новичок. Это мой метод OnCreate из MainActivity.java:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
NumberPicker np = new NumberPicker(this);
np.setId(10);
np.setMaxValue(6);
np.setMinValue(2);
np.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
LinearLayout linearLayout = (LinearLayout) findViewById(R.layout.activity_main);
linearLayout.addView(np);
}
Когда этот код выполняется, ни один из элементов не View отображается на Android экране и «zygoteInit ошибка» выскакивает в Eclipse. Как мне изменить команду findViewById в строке до последнего, чтобы можно было добавить View (NumberPicker) в LinearLayout?