android 圖案片漸漸消失

來源:互聯網
上載者:User

布局:

main.xml:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_gravity="center_vertical|center_horizontal" >    <ImageView        android:id="@+id/image"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:src="@drawable/logo" />    <TextView        android:id="@+id/tv"        android:text="Welcom to mojia space"        android:layout_below="@drawable/logo"        android:layout_width="wrap_content"        android:layout_height="wrap_content"       /></RelativeLayout>

other.xml:

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:layout_gravity="center_vertical|center_horizontal" >    <Button        android:id="@+id/button1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_alignParentLeft="true"        android:layout_alignParentTop="true"        android:text="Button" /></RelativeLayout>

主Activity:

package wangxin.Activity;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.widget.ImageView;import android.widget.TextView;public class WelcomePicActivity extends Activity {/** Called when the activity is first created. */private TextView tv = null;private ImageView image = null;private Handler handler = null;private int alpha = 255;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);tv = (TextView) findViewById(R.id.tv);image = (ImageView) findViewById(R.id.image);image.setAlpha(alpha);Thread thread =  new Thread(new UpdateImageThread());thread.start();handler = new Handler() {@Overridepublic void handleMessage(Message msg) {// TODO Auto-generated method stubSystem.out.println(msg);super.handleMessage(msg);image.setAlpha(alpha);image.invalidate();}};}class UpdateImageThread implements Runnable{private int b =0 ;@Overridepublic void run() {// TODO Auto-generated method stubb = initApp();try {while (b < 2) {if (b == 0) {//延時2秒後,每50毫秒更新一次imageThread.sleep(2000);b = 1;} else {Thread.sleep(50);}updateApp(b);}} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}protected void updateApp(int b) {// TODO Auto-generated method stubalpha = alpha - 5;if (alpha <= 0) {b = 2;Intent intent = new Intent(this, Frm_Addbills.class);startActivity(intent);finish();}handler.sendMessage(handler.obtainMessage());}public int initApp() {int b = 0;return b;}}

otherActivity:

package wangxin.Activity;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class Frm_Addbills extends Activity {private Button btn = null;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.other);btn = (Button) findViewById(R.id.button1);btn.setOnClickListener(new BtnListener());}class BtnListener implements OnClickListener {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubFrm_Addbills.this.finish();}}}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.