Если я пытаюсь раздуть представление внутри фрагмента, я получаю NULL.. Например:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Here I will inflate my view using the layout ID & return.
return view;
}
Всякий раз, когда нажимается кнопка, мне нужно создать кнопку динамического просмотра, например: и добавить к LinearLayout. Я хотел бы выполнить эту операцию внутри моего класса фрагмента следующим образом:
public void addPlaces() {
Button button = new Button(null);
button.setText("button name");
// e.g. like adding button to enter code here linear layout
linearLayout.addView(button);
}
Итак, если я надуваю LinearLayout внутри onCreateView и использую его в классе add, я получаю NULL. Как достичь?