ここに私のコード:
LinearLayout ll = (LinearLayout) View.inflate(TabAndPlay.this, R.layout.current_play, null);
TextView tv = new TextView(TabAndPlay.this);
tv.setText("hallo");
tv.setBackgroundColor(Color.GRAY);
ll.addView(tv);
current_play.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/aktuelle_spiele"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
R.id.llPlay (xml にそう表示されます)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip">
<LinearLayout
android:id="@+id/llPlay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
ここに onOptionsItemSelected() があります
case R.id.current_play:
LinearLayout mainLayout = (LinearLayout) findViewById(R.id.llPlay);
mainLayout.removeAllViews();
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.current_play, mainLayout, true);
return true;
メニュー項目をクリックすると、R.id.llPlays の現在のビューがすべて削除されます。current_play のボタンが表示されます。しかし、「Here my code」の TextView は表示されません。なぜですか? 私のエラーはどこですか?