<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按鈕時調(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);

                //生成一個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">計算結(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 生命的綻放 閱讀(404) 評論(0)  編輯  收藏 所屬分類: Android


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


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

    導(dǎo)航

    統(tǒng)計

    常用鏈接

    留言簿(5)

    隨筆分類(94)

    隨筆檔案(93)

    文章分類(5)

    文章檔案(5)

    相冊

    JAVA之橋

    SQL之音

    兄弟之窗

    常用工具下載

    積分與排名

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 久久精品国产亚洲av天美18| 高清永久免费观看| 国产成人精品久久亚洲高清不卡 | 香蕉免费看一区二区三区| 亚洲精选在线观看| 国产精品成人无码免费| 免费av片在线观看网站| 亚洲爆乳少妇无码激情| 亚洲阿v天堂在线| 国产视频精品免费| 99在线观看精品免费99| 黄色三级三级三级免费看| 久久亚洲精品无码VA大香大香| 国产黄色片在线免费观看| 免费看黄的成人APP| 性色av极品无码专区亚洲| 久久伊人久久亚洲综合| av无码东京热亚洲男人的天堂| 67pao强力打造高清免费| 美女被爆羞羞网站免费| 亚洲国产成人va在线观看网址| 亚洲一级特黄大片在线观看| 日韩精品成人无码专区免费| a级毛片毛片免费观看久潮喷 | 亚洲成人黄色在线| 久久国产成人精品国产成人亚洲 | 成人免费一区二区无码视频| a级毛片免费高清毛片视频| 亚洲综合激情五月色一区| 久久精品亚洲日本佐佐木明希| 免费人成视频在线观看视频| 日韩一区二区a片免费观看| 久久精品免费观看国产| 无遮挡国产高潮视频免费观看| 97久久国产亚洲精品超碰热| 亚洲AV永久无码精品水牛影视| 亚洲精品第一国产综合境外资源| 在线播放免费播放av片| 一个人看www在线高清免费看 | 日本人的色道免费网站| 外国成人网在线观看免费视频 |