Android Application loading progress Design

Source: Internet
Author: User

Android is loading data (accessing the database or loading network data) and needs to display the loading progress. In fact, this is very simple!

1. xml layout file for data loading progress display

<? XML version = "1.0" encoding = "UTF-8"?>
<Framelayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent">
<Linearlayout Android: Background = "@ drawable/Alert" Android: layout_gravity = "center" Android: paddingleft = "10dip" Android: paddingright = "10dip" Android: paddingtop = "20dip" Android: paddingbottom = "20dip" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: Orientation = "horizontal">
<Progressbar
Android: Id = "@ Android: ID/progress"
Android: layout_marginright = "15dip"
Android: layout_gravity = "center_vertical | right"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
Android: progressdrawable = "@ drawable/White"
Style = "? Android: ATTR/progressbarstylesmall ">
</Progressbar>
<Textview Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: Id = "@ Android: ID/text1" Android: textcolor = "# fff" Android: TEXT = "loading... "> </textview>
</Linearlayout>
</Framelayout>

 

2. Data Loading progress display class

Public class loadingalert {
Private view mview;
Private textview mtext;
Public loadingalert (activity ){
Mview = layoutinflater. From (activity). Inflate (R. layout. loadingalert, null );
Mtext = (textview) mview. findviewbyid (Android. R. Id. text1 );
Linearlayout. layoutparams lay = new linearlayout. layoutparams (layoutparams. fill_parent, layoutparams. fill_parent );
Lay. Gravity = gravity. Center;
Activity. addcontentview (mview, lay );
}
 
Public loadingalert (dialog DIALOG ){
Mview = dialog. getlayoutinflater (). Inflate (R. layout. loadingalert, null );
Mtext = (textview) mview. findviewbyid (Android. R. Id. text1 );
Viewgroup. layoutparams lay = new viewgroup. layoutparams (dialog. getwindow (). peekdecorview (). getwidth (), dialog. getwindow (). peekdecorview (). getheight ());
Dialog. addcontentview (mview, lay );
}
 
Public void setmessage (string message ){
Mtext. settext (Message );
}
 
Public void hide (){
Mview. setvisibility (view. Gone );
}
 
Public void show (){
Mview. setvisibility (view. Visible );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.