您的位置:首页 > 其它

两种数据加载动画

2015-05-20 01:22 141 查看
android 数据加载动画:



<FrameLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<RelativeLayout
android:id="@+id/rl_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<ProgressBar
android:layout_centerInParent="true"
android:id="@+id/pb"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<TextView
android:layout_marginTop="30dp"
android:layout_below="@+id/pb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="加载数据中....." />

</RelativeLayout>
</FrameLayout>

<ListView
android:id="@+id/lv_black"
android:layout_below="@+id/rl1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>


代码的方式:

public class TreasureActivity extends Activity implements OnClickListener {

private TextView money, integral, bill;
private LinearLayout addBankCard, transfer, myBankCard, tixian,
creditCard/* ,taojin */;
private ExecutorService fixedThreadPool;
private Bitmap userImg;// 用户头像
private String yue, allIntegral;
private Button setting,topay;
private PreferencesHelper ph;
private ProgressDialog dialog;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.treasure_activity_layout);
// 注册默认的未捕捉异常处理类
Thread.setDefaultUncaughtExceptionHandler(AppException
.getAppExceptionHandler());
AppManager.getAppManager().addActivity(this);
// 创建一个定长线程池,可控制线程最大并发数,超出的线程会在队列中等待:
fixedThreadPool = Executors.newFixedThreadPool(3);
// Toast.makeText(getApplicationContext(), Constant.portrait, 0).show();
ph = new PreferencesHelper(getApplicationContext(), Constants.ANZIDate);
initView();

}

@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
getMoney();
getUserData();
}

/*
* 联网获取用户数据
*/
private void getUserData() {
// 获得用户头像
if ("null".equals(ph.getValue("portrait"))) {// 用户头像为空
// userIc.setImageResource(R.drawable.icon_head);
} else {
// 获得线程消息
final Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
String s = (String) msg.obj;
if ("ok".equals(s)) {
integral.setText(allIntegral);
dialog.dismiss();
} else if ("no".equals(s)) {
Toast.makeText(getApplicationContext(), "系统问题", 1)
.show();
dialog.dismiss();
}
}
};
dialog = ProgressDialog.show(this, null, "正在加载……请稍后", true, true);
dialog.setCanceledOnTouchOutside(false);
fixedThreadPool.execute(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
String result = Net.yue(Constant.netcard
+ "/checkpoints.shtml", "uid",
ph.getValue("uid"));
// 解析json字符串
result = result.substring(1, result.length() - 1);
Log.i("查询结果", result);
JSONObject jsonObject = new JSONObject(result);
allIntegral = jsonObject.getString("message");
// 通知UI
Message msg = new Message();
msg.obj = "ok";
handler.sendMessage(msg);
} catch (Exception e) {
e.printStackTrace();
// 通知UI
Message msg = new Message();
msg.obj = "no";
handler.sendMessage(msg);
}
}
});
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: