下载中点击暂停没反应
暂停没反应 不知道怎么写了 看代码
holder.btns .setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { [color=#FF0000]if (flag == 0){//判断点击标记[/color] holder.ratingBarScore.setVisibility(View.GONE); holder.pro.setVisibility(View.VISIBLE); holder.textView.setVisibility(View.VISIBLE); if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ }else {// Toast.makeText(this, "没有SD卡", 1000).show(); Log.v("wjp", "7889900"); } final String downloadUrl =(String)v.getTag(); Thread thread = new Thread(){ int count = 0; public void run(){ Log.v("ccf", "onClick"); try { downLoadFile(context, downloadUrl, gameName, holder); openFile(context, new File("/sdcard/9twan/"+ gameName +".apk")); if(!WebHelper.REGISTER_FLAG){ Log.v("GamesInfoListAdapter", "WebHelper.REGISTER_FLAG == false"); String imei, mac, mobile_number, model, brand; boolean flag; TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); imei = tm.getDeviceId(); if(imei == null){ imei = "CUSTOM" + WebHelper.generateRandomIMEIString(15); } mac = null;// mac = tm.getDeviceId(); if(mac == null){ mac = "CUSTOM" + WebHelper.generateRandomMacString(17); } mobile_number = tm.getLine1Number(); model = tm.getLine1Number(); brand = tm.getLine1Number(); flag = WebHelper.regDevice(context, "install", imei, mac, mobile_number, model, brand); if(flag){ WebHelper.REGISTER_FLAG = true; Log.v("GamesInfoListAdapter", "WebHelper.REGISTER_FLAG == true"); } } }catch (Exception e){ e.printStackTrace(); } } }; Log.v("wjp", "正在运行"+thread.getName()); thread.start(); Toast.makeText(context, "开始下载" + gameName, 0).show(); holder.btns.setBackgroundResource(R.drawable.tab_out); [color=#FF0000]flag =1;[/color]//这里是需要暂停的 这里怎么写? }else { if(Thread.currentThread() !=null){ Thread.interrupted();// Thread = null; }// thread.// Thread.interrupted();//暂停 返回boolean// Thread.sleep(3000);// Thread. holder.btns.setBackgroundResource(R.drawable.tab_install); flag =0; } } }); } return convertView;