<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    想飛就別怕摔

    大爺?shù)牟M罵人

    Android學(xué)習(xí)筆記(一)初步Activity與Intent【乘法運(yùn)算】

    MyActivity.java
    package zzn.android;

    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;

    public class MyActivity extends Activity
    {
        /** Called when the activity is first created. */
        private Button myButton = null;
        private EditText myEdit01;
        private EditText myEdit02;
        private TextView myText01;
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);

            myEdit01 = (EditText)findViewById(R.id.edit01);
            myEdit02 =(EditText)findViewById(R.id.edit02);
            myText01 = (TextView)findViewById(R.id.text01);
            myButton = (Button)findViewById(R.id.myButton);

            myText01.setText(R.string.textView01);
            myButton.setText(R.string.myButton);
            myButton.setOnClickListener(new MyButtonListener());
            }

        // 當(dāng)點(diǎn)擊鍵盤上的menu按鈕時(shí)調(diào)用此方法。
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
        menu.add(1,1,1,R.string.exit);
        menu.add(1,2,2,R.string.about);
        return super.onCreateOptionsMenu(menu);
    }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            if(item.getItemId() == 1){
                finish();
            }
            return super.onOptionsItemSelected(item);
        }

        class MyButtonListener implements View.OnClickListener {
            @Override
            public void onClick(View view) {
                String  edit01Str = myEdit01.getText().toString();
                String edit02Str = myEdit02.getText().toString();

                Intent intent = new Intent();
                intent.putExtra("edit01",edit01Str);
                intent.putExtra("edit02",edit02Str);

                intent.setClass(MyActivity.this,MyActivity01.class);
                startActivity(intent);

                //生成一個(gè)Intent對象
               /* Intent intent = new Intent();
                intent.putExtra("testExtra","123456");
                intent.setClass(MyActivity.this,MyActivity01.class);
                MyActivity.this.startActivity(intent);
    */

                /*Uri uri = Uri.parse("smsto://0800000123");
                Intent intent   = new Intent(Intent.ACTION_SENDTO,uri);
                intent.putExtra("sms_body","this is sms test");
                startActivity(intent);
    */

            }
        }

    }

    MyActivity02.java
    package zzn.android;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.TextView;

    public class MyActivity01 extends Activity {
        private TextView myTextView = null;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.other);
            Intent intent = getIntent();
            String edit01Str = intent.getStringExtra("edit01");
            String edit02Str = intent.getStringExtra("edit02");
            int intEdit01 = Integer.parseInt(edit01Str);
            int intEdit02 = Integer.parseInt(edit02Str);
            int result = intEdit01*intEdit02;
            myTextView = (TextView)this.findViewById(R.id.myTextView);
            myTextView.setText(result+"");
        }
    }

    main.xml
    <?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"
        
    >
        <EditText
            
    android:id="@+id/edit01"
            android:layout_width
    ="fill_parent"
            android:layout_height
    ="wrap_content"
            
    />
        <TextView
            
    android:id="@+id/text01"
            android:layout_height
    ="wrap_content"
            android:layout_width
    ="fill_parent"
            
    />
        <EditText
                
    android:id="@+id/edit02"
                android:layout_width
    ="fill_parent"
                android:layout_height
    ="wrap_content"
                
    />

        <Button
            
    android:id="@+id/myButton"
            android:layout_width
    ="fill_parent"
            android:layout_height
    ="wrap_content"
    android:text
    ="點(diǎn)擊我跳轉(zhuǎn)"    />
    </LinearLayout>

    other.xml
    <?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:id="@+id/myTextView"
            android:layout_width
    ="fill_parent"
            android:layout_height
    ="wrap_content"
            
    />
    </LinearLayout>

    String.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <string name="app_name">myAndroid01</string>
        <string name="myTextView">otherActivity</string>
        <string name="textView01">乘以</string>
        <string name="myButton">計(jì)算結(jié)果</string>
        <string name="exit">退出</string>
        <string name="about">關(guān)于</string>
    </resources>

    AndroidManifest.xml
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
              package
    ="zzn.android"
              android:versionCode
    ="1"
              android:versionName
    ="1.0">
        <uses-sdk android:minSdkVersion="8"/>
        <application android:label="@string/app_name">
            <activity android:name="MyActivity"
                      android:label
    ="@string/app_name">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
            </activity>

            <activity android:name="MyActivity01"
                      android:label
    ="@string/myTextView"/>


        </application>
    </manifest> 







    posted on 2012-05-28 11:32 生命的綻放 閱讀(416) 評論(0)  編輯  收藏 所屬分類: Android


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    <2012年5月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿(5)

    隨筆分類(94)

    隨筆檔案(93)

    文章分類(5)

    文章檔案(5)

    相冊

    JAVA之橋

    SQL之音

    兄弟之窗

    常用工具下載

    積分與排名

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 亚洲国产aⅴ综合网| 男男gay做爽爽免费视频| 亚洲AV无码成人专区片在线观看| 亚洲麻豆精品国偷自产在线91| 国产免费观看黄AV片| 好爽…又高潮了免费毛片| 国产一精品一AV一免费孕妇| 91精品免费不卡在线观看| 你懂的免费在线观看网站| 久久国产精品国产自线拍免费| 国产成人AV片无码免费| 日韩中文字幕免费视频| 中国xxxxx高清免费看视频| 最好看的中文字幕2019免费| **俄罗斯毛片免费| 在线观看的免费网站| 成人性生交视频免费观看| 日韩免费无砖专区2020狼| 四虎在线播放免费永久视频 | 曰批免费视频播放免费| 香蕉视频免费在线播放| 国产高清视频免费在线观看| a色毛片免费视频| 91短视频在线免费观看| 2020久久精品国产免费| 午夜老司机免费视频| 免费夜色污私人影院在线观看| 国产亚洲美女精品久久久2020| 亚洲AV永久无码精品| 亚洲色av性色在线观无码| 久久成人a毛片免费观看网站| 日本免费大黄在线观看| 黄色片在线免费观看| 国产老女人精品免费视频| 久久亚洲欧洲国产综合| 亚洲宅男永久在线| 亚洲人成网站在线播放2019| 老外毛片免费视频播放| 日韩电影免费在线观看| 欧美日韩国产免费一区二区三区| 亚洲AV无码一区二区三区国产|