我正在编写一个骰子游戏作为一个假期项目,但我现在有点卡住了:我的代码中没有任何错误,但应用程序仍然无法启动。我真的不明白为什么。我尝试清理项目,修复属性,但没有任何效果。任何帮助都会很棒。
Java代码:
package com.bdec.tritsen;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class NamenActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_namen);
}
public void spelregels(View v)
{
Toast.makeText(getApplicationContext(), "Spelregels komen binnenkort", Toast.LENGTH_SHORT).show();
}
public void beginSpel(View v)
{
EditText Field1 = (EditText) findViewById(R.id.naam1);
EditText Field2 = (EditText) findViewById(R.id.naam2);
EditText Field3 = (EditText) findViewById(R.id.naam3);
EditText Field4 = (EditText) findViewById(R.id.naam4);
EditText Field5 = (EditText) findViewById(R.id.naam5);
EditText Field6 = (EditText) findViewById(R.id.naam6);
EditText Field7 = (EditText) findViewById(R.id.naam7);
EditText Field8 = (EditText) findViewById(R.id.naam8);
EditText Field9 = (EditText) findViewById(R.id.naam9);
EditText Field10 = (EditText) findViewById(R.id.naam10);
String naam1 = Field1.getText().toString();
String naam2 = Field2.getText().toString();
String naam3 = Field3.getText().toString();
String naam4 = Field4.getText().toString();
String naam5 = Field5.getText().toString();
String naam6 = Field6.getText().toString();
String naam7 = Field7.getText().toString();
String naam8 = Field8.getText().toString();
String naam9 = Field9.getText().toString();
String naam10 = Field10.getText().toString();
}
}
按钮的 XML 代码:
<Button
android:id="@+id/buttonBegin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Begin"
android:onClick="beginSpel"/>
<Button
android:id="@+id/buttonSpelregels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Spelregels"
android:onClick="spelregels" />