• 两种数据加载动画


    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);
    					}
    				}
    			});
    		}
    	}
    
  • 相关阅读:
    [C/C++]Fibonacci numbers
    使用VS调试时,被调试进程如何被断下来的。
    Windows下动态加载可执行代码原理简述
    发个JD, 求人被我卖
    使用Windbg知道程序运行时的命令行参数.
    How to debug usermode process using kernelmode windbg in Win7
    This is a test
    多核时代,还在使用任务管理器来看程序的性能吗?
    六种异常处理的陋习
    巧记Java访问控制描述符(Access Control Modifier)public, private, protected
  • 原文地址:https://www.cnblogs.com/childhooding/p/4516108.html
Copyright © 2020-2023  润新知