編輯:關於Android編程
在android中進度條和選項卡的使用一文中簡單介紹了進度條的使用,但是該文中只介紹了普通進度條(包括標題欄進度條和水平進度條等)的使用,那麼在本文中將補充一種對話框式的進度條,它在實際中運用更為廣泛,代碼如下:
Activity:
package com.home;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
private Button showProgressDialogBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
showProgressDialogBtn = (Button) findViewById(R.id.main_btn_show);
showProgressDialogBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// 顯示對話框
showDialog(0);
}
});
}
@Override
protected Dialog onCreateDialog(int id) {
// 實例化進度條對話框
ProgressDialog dialog = new ProgressDialog(this);
dialog.setTitle("測試進度條對話框");
dialog.setIndeterminate(true);
dialog.setMessage("程序正在加載請稍後。。。");
dialog.setCancelable(true);
return dialog;
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/main_btn_show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="顯示進度條對話框" />
</LinearLayout>
附上圖片效果:
Android實現標題顯示隱藏功能
本文實例嘗試模仿實現Android標題顯示隱藏功能,通過給listview設置 mListView.setOnTouchListener 監聽 重寫ontouch方法 監
android-合並兩張圖片bitmap
Bitmap bitmap1; Bitmap bitmap2; Bitmap bitmap3 = Bitmap.createBitmap(bitmap1.getWidth
Android Development Notes-2
Summary:SDK, ADB, Active, Intents and Tasks-The Android SDK is made of mostly off-the
Android 基於Socket的聊天室實例
Socket是TCP/IP協議上的一種通信,在通信的兩端各建立一個Socket,從而在通信的兩端之間形成網絡虛擬鏈路。一旦建立了虛擬的網絡鏈路,兩端的程序就可以通過虛擬鏈