編輯:關於Android編程
MainActivity如下:
package cc.testprogressdialog; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; /** * Demo描述: * 利用代碼在屏幕中間位置顯示ProgressDialog和ProgressBar * * 參考資料: * 1 http://blog.csdn.net/lfdfhl/article/details/18913435 * 2 http://blog.csdn.net/lfdfhl/article/details/9299075 * 3 http://rocye.iteye.com/blog/1258936 * Thank you very much * * 如果在某個線性布局中動態添加一個控件,並且想讓該控件在布局中居中. * 也可采用createProgressBar()方法中類似的方式 * */ public class MainActivity extends Activity { private Context mContext; private ProgressBar mProgressBar; private ProgressDialog mProgressDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //顯示ProgressBar createProgressBar(); //顯示ProgressDialog //createProgressDialog(); } private void createProgressBar(){ mContext=this; //整個Activity布局的最終父布局,參見參考資料 FrameLayout rootFrameLayout=(FrameLayout) findViewById(android.R.id.content); FrameLayout.LayoutParams layoutParams= new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams.gravity=Gravity.CENTER; mProgressBar=new ProgressBar(mContext); mProgressBar.setLayoutParams(layoutParams); mProgressBar.setVisibility(View.VISIBLE); rootFrameLayout.addView(mProgressBar); } private void createProgressDialog(){ mContext=this; mProgressDialog=new ProgressDialog(mContext); mProgressDialog.setMessage("...請您稍等..."); mProgressDialog.show(); } }
Android之屏幕適配Android之屏幕適配 適配方式一圖片適配 適配方式二dimensxml文件適配 適配方式三布局文件適配 適配方式四java代碼適配 適配方式五
“` import android.content.Context;import android.content.res.TypedArray;im
前言在上篇文章詳細介紹了XML及其DOM、SAX、PULL解析方法和對比,那麼今天,我們來介紹同樣作為主流的數據交換格式-JSON!定義JavaScript Object
前言:前面兩篇分別介紹了:Android-Universal-Image-Loader (圖片異步加載緩存庫)的使用配置Android-Universal-Image-L