<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對(duì)象
               /* 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 生命的綻放 閱讀(403) 評(píng)論(0)  編輯  收藏 所屬分類: Android


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


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

    導(dǎo)航

    統(tǒng)計(jì)

    常用鏈接

    留言簿(5)

    隨筆分類(94)

    隨筆檔案(93)

    文章分類(5)

    文章檔案(5)

    相冊(cè)

    JAVA之橋

    SQL之音

    兄弟之窗

    常用工具下載

    積分與排名

    最新評(píng)論

    閱讀排行榜

    主站蜘蛛池模板: 99久久免费中文字幕精品| 好男人视频在线观看免费看片 | 国产亚洲美女精品久久久| 你懂的网址免费国产| 亚洲精品亚洲人成在线播放| 免费在线观看理论片| 性xxxx视频免费播放直播| 亚洲精品无码人妻无码| 亚洲色爱图小说专区| 成年女人毛片免费视频| 热99RE久久精品这里都是精品免费| 亚洲天堂男人影院| 国产成人麻豆亚洲综合无码精品| 国产在线观看免费观看不卡| 九九99热免费最新版| 亚洲国产精品免费观看 | 亚洲国产91精品无码专区| 2015日韩永久免费视频播放| 色婷婷综合缴情综免费观看| 亚洲欧洲国产精品久久| 亚洲欧洲久久久精品| 成年女人免费视频播放体验区| a级毛片免费全部播放| 95免费观看体验区视频| 日韩色视频一区二区三区亚洲| 亚洲一本综合久久| 午夜免费福利片观看| 亚洲国产电影在线观看| 亚洲字幕在线观看| 亚洲无成人网77777| 亚洲精品美女视频| 久久精品国产亚洲AV无码麻豆 | 污视频网站在线免费看| 国产综合激情在线亚洲第一页| 亚洲精品GV天堂无码男同| 亚洲av成人一区二区三区观看在线 | 久久青青草原亚洲av无码app| 亚洲精品线在线观看| 亚洲成人动漫在线| 亚洲黄色网址在线观看| 亚洲午夜电影在线观看|