私はメインのXMLファイルを作成していますが、正しいとは確信していますが、レイアウトを画面に表示する方法はわかりません。私はすべての異なるウィジェットの変数を作成し、R.id.mainと同じ変数に設定しようとしましたが、画面上に何も表示されませんでした。基本的に私はどのように画面上のxmlに入っているのかを表示する方法を理解していません。これは私のコードです、誰かが私が間違っていると説明してください。Androidレイアウトの問題 - xmlを画面に表示する
public class MinesweeperActivity extends Activity {
private TableLayout all;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
all = (TableLayout)findViewById(R.id.all);
}
}
// this is my xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/all"
android:stretchColumns="*"
android:background="@drawable/bground"
>
<TableRow>
<TextView
android:id="@+id/Timer"
android:layout_column="0"
android:text="000" />
<TextView
android:id="@+id/Counter"
android:layout_column="2"
android:text="000" />
<ImageButton
android:id="@+id/Face"
android:layout_column="1"
android:background="@drawable/faces"
android:layout_height="50px" />
</TableRow>
<TableRow>
<TextView
android:layout_column="0"
android:layout_height="50px"
android:layout_span="3"
android:padding="10dip"/>
</TableRow>
<TableRow>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Mines"
android:layout_width="260px"
android:layout_height="260px"
android:gravity="bottom"
android:stretchColumns="*"
android:layout_span="3"
android:padding="5dip" >
</TableLayout>
</TableRow>
</TableLayout>
ありがとう、これはそれを解決しました。 – Dave