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.support.v7.app.AppCompatActivity; |
10 | import android.view.Menu; |
11 | import android.view.MenuItem; |
13 | public class MainActivity extends AppCompatActivity { |
15 | protected void onCreate( Bundle savedInstanceState ) { |
16 | super .onCreate( savedInstanceState ); |
17 | setContentView( R.layout.activity_main ); |
18 | final EditText name = (EditText) findViewById( R.id.name ); |
19 | final Button button = (Button) findViewById( R.id.next ); |
20 | button.setOnClickListener( |
21 | new View.OnClickListener( ) { |
22 | public void onClick( View v ) { |
23 | /** Here i calls a new screen. **/ |
24 | Intent i = new Intent( MainActivity. this , NextActivity. class ); |
25 | i.putExtra( "name" , name.getText( ).toString( ) ); |
33 | public boolean onCreateOptionsMenu( Menu menu ) { |
35 | getMenuInflater( ).inflate( R.menu.menu_main, menu ); |
40 | public boolean onOptionsItemSelected( MenuItem item ) { |
44 | int id = item.getItemId( ); |
47 | if ( id == R.id.action_settings ) { |
50 | else if ( id == R.id.next ) { |
51 | Intent i = new Intent( MainActivity. this , NextActivity. class ); |
54 | return super .onOptionsItemSelected( item ); |
|