欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 開發(fā)使用PopupWindow實現(xiàn)加載等待界面功能示例

 更新時間:2020年05月21日 10:51:05   作者:LIFE_R  
這篇文章主要介紹了Android 開發(fā)使用PopupWindow實現(xiàn)加載等待界面功能,結(jié)合實例形式分析了Android使用PopupWindow組件實現(xiàn)加載等待界面功能相關(guān)布局與功能實現(xiàn)技巧,需要的朋友可以參考下

本文實例講述了Android 開發(fā)使用PopupWindow實現(xiàn)加載等待界面功能。分享給大家供大家參考,具體如下:

實現(xiàn)加載等待界面我用了兩種方式,一種是用PopupWindow實現(xiàn),另一種便是用Activity實現(xiàn)。用Activity實現(xiàn)方法請見我的另一篇博客:

Android 使用Activity實現(xiàn)加載等待界面

首先看效果:

用PopupWindow實現(xiàn)此功能還是比較簡單的,首先我們寫一個布局,只有一個登錄按鈕,用于觸發(fā)等待界面:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/activity_main"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 android:orientation="vertical"
 tools:context="com.toprs.myapplication.MainActivity">

 <Button
  android:text="登錄"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:onClick="loginClick"
  android:id="@+id/button2"/>
</LinearLayout>

然后為登錄按鈕添加監(jiān)聽事件:

package com.wang.myapplication;

import ...

public class MainActivity extends AppCompatActivity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
 }

 public void loginClick(View v){
  final PopupWindow popupWindow = new PopupWindow();
  popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
  popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
  popupWindow.setFocusable(true);
  View view = LayoutInflater.from(this).inflate(R.layout.popup,null);
  popupWindow.setContentView(view);
  popupWindow.showAtLocation(getWindow().getDecorView(), Gravity.CENTER,0,0);

  new Handler().postDelayed(new Runnable() {
   @Override
   public void run() {
    Toast.makeText(MainActivity.this, "登錄成功", Toast.LENGTH_SHORT).show();
    popupWindow.dismiss();
   }
  },2000);
 }
}

其中彈出的PopupWindow需要一個布局,也就是簡單放入一個ProgressBar:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="200dp"
    android:layout_height="200dp">

 <ProgressBar
  android:id="@+id/progressBar4"
  style="?android:attr/progressBarStyle"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerInParent="true"/>

</RelativeLayout>

大功告成,運行一下即可??!

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android控件用法總結(jié)》、《Android開發(fā)入門與進階教程》、《Android視圖View技巧總結(jié)》、《Android編程之a(chǎn)ctivity操作技巧總結(jié)》、《Android數(shù)據(jù)庫操作技巧總結(jié)》及《Android資源操作技巧匯總

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

  • Android Activity被回收的情況分析

    Android Activity被回收的情況分析

    Activity作為Android四大組件之一,他的啟動絕對沒有那么簡單。這里涉及到了系統(tǒng)服務(wù)進程,啟動過程細節(jié)很多,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值
    2022-11-11
  • Android GridView簡單實例

    Android GridView簡單實例

    這篇文章主要為大家詳細介紹了Android GridView簡單實例,簡單實現(xiàn)九宮格效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • Android中的設(shè)計模式

    Android中的設(shè)計模式

    常用的設(shè)計模式有以下八種:單例、工廠、觀察者、代理、命令、適配器、合成、訪問者。下面通過本文給大家介紹下android中的設(shè)計模式,感興趣的朋友一起看看吧
    2016-09-09
  • Android?NotificationListenerService?通知服務(wù)原理解析

    Android?NotificationListenerService?通知服務(wù)原理解析

    這篇文章主要為大家介紹了Android?NotificationListenerService?通知服務(wù)原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • Android編程實現(xiàn)實時監(jiān)聽EditText文本輸入的方法

    Android編程實現(xiàn)實時監(jiān)聽EditText文本輸入的方法

    這篇文章主要介紹了Android編程實現(xiàn)實時監(jiān)聽EditText文本輸入的方法,結(jié)合實例形式分析了EditText控件及事件響應(yīng)相關(guān)操作技巧,需要的朋友可以參考下
    2017-06-06
  • Android開發(fā)模仿qq視頻通話懸浮按鈕(實例代碼)

    Android開發(fā)模仿qq視頻通話懸浮按鈕(實例代碼)

    這篇文章主要介紹了Android開發(fā)模仿qq視頻通話懸浮按鈕功能的實例代碼,需要的的朋友參考下
    2017-02-02
  • Android簡單實現(xiàn)動態(tài)權(quán)限獲取相機權(quán)限及存儲空間等多權(quán)限

    Android簡單實現(xiàn)動態(tài)權(quán)限獲取相機權(quán)限及存儲空間等多權(quán)限

    這篇文章主要介紹了Android簡單實現(xiàn)動態(tài)權(quán)限獲取相機權(quán)限及存儲空間等多權(quán)限,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的朋友可以參考一下
    2022-07-07
  • flutter簡單使用案例

    flutter簡單使用案例

    這篇文章主要介紹了使用Flutter短視頻上滑翻頁效果,本篇介紹了?Flutter的翻頁組件PageView的使用,通過?PageView可以輕松實現(xiàn)類似短視頻的縱向上滑翻頁的效果,也可以實現(xiàn)橫向翻頁效果(如閱讀類軟件),需要的朋友可以參考下
    2023-05-05
  • 談?wù)凙ndroid中的Divider是個什么東東

    談?wù)凙ndroid中的Divider是個什么東東

    在Android應(yīng)用開發(fā)中會經(jīng)常碰到一個叫divider的東西,就是兩個View之間的分割線,本文主要給大家介紹android中的divider相關(guān)知識,需要的朋友可以參考下
    2016-03-03
  • Android自定義控件仿ios下拉回彈效果

    Android自定義控件仿ios下拉回彈效果

    這篇文章主要為大家詳細介紹了Android自定義控件仿ios下拉回彈效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-01-01

最新評論