01 | package com.example.wenchen.helloworld; |
03 | import android.app.Activity; |
04 | import android.content.Intent; |
05 | import android.os.Bundle; |
06 | import android.view.View; |
07 | import android.widget.Button; |
08 | import android.widget.EditText; |
09 | import android.view.Menu; |
10 | import android.view.MenuItem; |
12 | public class MainActivity extends Activity { |
14 | protected void onCreate( Bundle savedInstanceState ) { |
15 | super .onCreate( savedInstanceState ); |
16 | setContentView( R.layout.activity_main ); |
17 | final EditText name = (EditText) findViewById( R.id.name ); |
18 | final Button button = (Button) findViewById( R.id.next ); |
19 | button.setOnClickListener( |
20 | new View.OnClickListener( ) { |
21 | public void onClick( View v ) { |
22 | /** Here i calls a new screen. **/ |
23 | Intent i = new Intent( MainActivity. this , NextActivity. class ); |
24 | i.putExtra( "name" , name.getText( ).toString( ) ); |
32 | public boolean onCreateOptionsMenu( Menu menu ) { |
34 | getMenuInflater( ).inflate( R.menu.menu_main, menu ); |
39 | public boolean onOptionsItemSelected( MenuItem item ) { |
43 | int id = item.getItemId( ); |
46 | if ( id == R.id.action_settings ) { |
49 | else if ( id == R.id.next ) { |
50 | Intent i = new Intent( MainActivity. this , NextActivity. class ); |
53 | return super .onOptionsItemSelected( item ); |
|