0
LinearLayoutのビューをプログラムで置き換えたいと思っています。この方法は、XMLで定義されていることをいうことLinearLayoutのビューを置換する
public void drawView() {
//remove previous view, if exists
if(((LinearLayout) findViewById(R.id.chartView)).getChildCount() > 0) {
((LinearLayout) findViewById(R.id.chartView)).removeAllViewsInLayout();
}
//generate new view
CustomView view = new CustomView(this,parameters);
//add new view to layout
((LinearLayout) findViewById(R.id.linLayout)).addView(view);
}
のLinearLayout:私は、次の方法を試し
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linLayout">
</LinearLayout>
ビューが正しく描画される最初の時間(何ビューのLinearLayoutにまだ存在しない場合このプログラムで生成されたビューをプログラムによって置き換えるにはどうすればよいでしょうか?