Здравствуйте.
У меня проблема: не могу перерисовать View.
View view = null;
ViewPager pager = null;
TabPageIndicator tabIndicator = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
linearlayout = (LinearLayout) findViewById(R.id.LinearLayout1e);
linearlayout.addView(TabPage(0), new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
Button but = (Button) findViewById(R.id.act_bar_button_home);
but.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
linearlayout.addView(TabPage(1), new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
});
}
public View TabPage(int i) {
if (i == 1) {
pager.removeAllViews();
}
LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = new View(this);
view = inflater.inflate(R.layout.main_tab_layout, null);
pager = (ViewPager) view.findViewById(R.id.pager);
pager.setAdapter(new CustomFragmentAdapter(getSupportFragmentManager()));
tabIndicator = (TabPageIndicator) view.findViewById(R.id.indicator);
tabIndicator.setViewPager(pager);
tabIndicator.notifyDataSetChanged();
return view;
}
При запуске программы, view отображается. А при нажатии кнопки view удаляется, но заново не появляется. В чём может быть проблема? Подскажите, пожалуйста.