4月4日毕设日记

今天主要的工作是:

1,根据屏幕的像素,做了几张图片,用画图截的,可以精确到像素。

2,在学习怎么在两个activity之间调用,这样才能把开始屏幕和显示结果分开。

3,想在dialog里显示一张动图,这样OCR的时候,等待的时间,用户体验会好一点。


问题2解决了,http://jingyan.baidu.com/article/14bd256e52db60bb6c261266.html,这样就不需要建立两个activity了,只需要在两个xml之间跳转。

  1. 然后修改activity_main.XML的内容,代码如下:

    <?xml version="1.0" encoding="utf-8"?>

     <AbsoluteLayout

          android:layout_width="fill_parent"

           android:layout_height="fill_parent" 

            xmlns:android="http://schemas.android.com/apk/res/android" >

             <TextView android:id="@+id/text1" 

                 android:textSize="24sp"

                 android:layout_width="186px" 

                 android:layout_height="186px" 

            android:text="@string/layout1"/>

              <Button android:id="@+id/button1"

                   android:layout_width="300px" 

                   android:layout_height="wrap_content"

                    android:layout_x="50px" 

                    android:layout_y="100px"

                     android:text="Go to Layout2">   </Button>

                     

              </AbsoluteLayout>


  2. 然后修改mymain.XML的内容,代码如下:

    <?xml version="1.0" encoding="utf-8"?> 

    <AbsoluteLayout 

        android:layout_width="fill_parent" 

        android:layout_height="fill_parent"

         xmlns:android="http://schemas.android.com/apk/res/android" > 

         <TextView android:id="@+id/text2" 

             android:textSize="24sp" 

             android:layout_width="186px"

              android:layout_height="186px" 

               android:text="@string/layout2"/> 

               <Button android:id="@+id/button2"

                    android:layout_width="300px" 

                    android:layout_height="wrap_content"

                     android:layout_x="100px" 

                     android:layout_y="82px"

                      android:text="Go to Layout1"> 

                      </Button>

                      

               </AbsoluteLayout>


  3. 修改主函数代码如下:

    package com.example.learn1_4_jump;

    import android.app.Activity;

    import android.os.Bundle;

    import android.view.View;

    import android.widget.Button;

    public class MainActivity extends Activity {

    @Override

    protected void onCreate(Bundle savedInstanceState) { 

       super.onCreate(savedInstanceState); 

    setContentView(R.layout.activity_main); 

    Button b1=(Button)findViewById(R.id.button1);

    b1.setOnClickListener(new View.OnClickListener() {

    @Override

    public void onClick(View arg0) {

    // TODO Auto-generated method stub

    jump2();

    }

    });}

    private void jump2() {

    // TODO Auto-generated method stub

    setContentView(R.layout.mymain);

    Button b2=(Button)findViewById(R.id.button2);

    b2.setOnClickListener(new View.OnClickListener() {

    @Override

    public void onClick(View arg0) {

    // TODO Auto-generated method stub

    jump1();

    }

    });}

     

    public void jump1()

    { setContentView(R.layout.activity_main); 

    Button b1=(Button)findViewById(R.id.button1); 

    b1.setOnClickListener(new Button.OnClickListener() 

    { @Override public void onClick(View v) { 

    // TODO Auto-generated method stub

    jump2(); } } ); 

    }

    }


  4. 运行程序,如图:

  5. 主界面,如图,点击按钮,观察变化,如图:

    android编程3-两个activity的跳转
    android编程3-两个activity的跳转

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值