public class NewGame extends Activity implements OnClickListener{ EditText word; Button createGame; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.newgame); word = (EditText) findViewById(R.id.word); createGame = (Button) findViewById(R.id.createGame); createGame.setOnClickListener(this); } public void onClick(View v){ Intent i = new Intent(NewGame.this, Game.class); i.putExtra("word", word.getText().toString()); startActivity(i); } }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text="Create New Game" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="22sp" android:gravity="center"/> <EditText android:hint="Enter Word" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/word" android:password="true"/> <Button android:id="@+id/createGame" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Create Game" android:textSize="20sp"/> </LinearLayout>
createGame = (Button) findViewById(R.id.createGame);
Button
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)