国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android中Market的Loading效果實現方法

2020-04-11 11:22:56
字體:
來源:轉載
供稿:網友

本文實例講述了Android中Market的Loading效果實現方法。分享給大家供大家參考。具體如下:

在Android中,要實現Loading效果,一般情況下都使用ProgressDialog控件。ApiDemos/src/com/example/android/apis/view/ProgressBar3.java 提供兩個demo:

仔細看了Android Market,發現卻是不一樣的,請看截圖:

那到底如何實現呢?首先,我們創建一個布局文件,
res/layout/fullscreen_loading_indicator.xml, 其內容如下:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   android:gravity="center_vertical|center_horizontal"  android:orientation="horizontal"  android:id="@+id/fullscreen_loading_style"  android:layout_width="fill_parent"  android:layout_height="fill_parent"  > <ProgressBar  android:layout_gravity="center_vertical"android:layout_width="wrap_content"android:layout_height="wrap_content"style="?android:attr/progressBarStyleSmall"/><TextView  android:id="@+id/current_action"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_marginLeft="5.0dip"  android:text="@+string/loading"/></LinearLayout>

然后在main.xml 把它include 進來

<?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">  <LinearLayout android:orientation="vertical"     android:id="@+id/main_info"    android:visibility="gone"     android:layout_width="fill_parent"    android:layout_height="fill_parent">    <TextView android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:text="abc"></TextView>  </LinearLayout>  <LinearLayout android:orientation="vertical"     android:id="@+id/main_Loading"    android:layout_width="fill_parent"    android:layout_height="fill_parent">    <include android:visibility="visible"       android:layout_width="fill_parent"      android:layout_height="fill_parent"       layout="@layout/fullscreen_loading_style" />  </LinearLayout></LinearLayout>

主程序:

package com.tymx.fullloading;import android.app.Activity;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.view.View;import android.widget.LinearLayout;public class myFullLoading extends Activity {  /** Called when the activity is first created. */  private LinearLayout mLoadingLayout;  @Override  public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.main);    final Handler handler = new Handler(){      @Override      public void handleMessage(Message msg) {        // TODO Auto-generated method stub        super.handleMessage(msg);        if (msg.what==1){          mLoadingLayout = (LinearLayout)findViewById(R.id.fullscreen_loading_style);          mLoadingLayout.setVisibility(View.GONE);          LinearLayout mMain = (LinearLayout)findViewById(R.id.main_info);          mMain.setVisibility(View.VISIBLE);        }      }    };    new Thread(){      public void run(){        for (int i=0;i<1000;i++){          System.out.print(i+"");        }        Message msg = handler.obtainMessage(1,"flash");        handler.sendMessage(msg);      }    }.start();  }}

運行的效果為:

希望本文所述對大家的Android程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 武夷山市| 望城县| 安龙县| 林西县| 乌兰察布市| 荆门市| 伊川县| 汉寿县| 伊金霍洛旗| 名山县| 县级市| 四子王旗| 邹平县| 衡南县| 望城县| 抚顺市| 富蕴县| 阿坝| 绵阳市| 肇州县| 刚察县| 方城县| 广东省| 巴楚县| 河津市| 南宁市| 前郭尔| 霍州市| 双鸭山市| 二连浩特市| 阜南县| 星子县| 珲春市| 金昌市| 福泉市| 吴江市| 青川县| 井冈山市| 青川县| 平原县| 丹东市|