您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
- public class tween extends Activity {
- // 声明ImageView对象
- ImageView p_w_picpathView;
- // 声明TextView
- TextView textView;
- // ImageView的alpha值
- int p_w_picpath_alpha = 0;
- // Handler对象用来给UI_Thread的MessageQueue发送消息
- Handler mHandler;
- // 线程是否运行判断变量
- boolean isrung = false;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.tween);
- SysApplication.getInstance().addActivity(this);
- final Context con=this.getApplicationContext();
- isrung = true;
- // 获得ImageView的对象
- p_w_picpathView = (ImageView) this.findViewById(R.id.img);
- textView = (TextView) this.findViewById(R.id.tvgc);
- // 设置p_w_picpathView的Alpha值
- p_w_picpathView.setAlpha(p_w_picpath_alpha);
- textView.setAlpha(p_w_picpath_alpha);
- // 开启一个线程来让Alpha值递减
- new Thread(new Runnable() {
- @Override
- public void run() {
- while (isrung) {
- try {
- Thread.sleep(200);
- // 更新Alpha值
- updateAlpha();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }} }
- }).start();
- // 接受消息之后更新p_w_picpathview视图
- mHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
- super.handleMessage(msg);
- p_w_picpathView.setAlpha(p_w_picpath_alpha);
- // 设置textview显示当前的Alpha值
- textView.setAlpha(p_w_picpath_alpha);
- // 刷新视图
- p_w_picpathView.invalidate();
- try{
- if(p_w_picpath_alpha==255)
- {
- isNetworkConnected(con);
- }
- }
- catch(Exception e){}
- } };}
- // 更新Alpha
- public void updateAlpha() {
- if (p_w_picpath_alpha +7<= 255) {
- p_w_picpath_alpha += 7;
- }
- else {
- p_w_picpath_alpha = 255;
- isrung = false; }
- // 发送需要更新p_w_picpathview视图的消息-->这里是发给主线程
- mHandler.sendMessage(mHandler.obtainMessage());
- }
- public void isNetworkConnected(Context context) {
- if (context != null) {
- ConnectivityManager mConnectivityManager = (ConnectivityManager)context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
- if (mNetworkInfo != null) {
- NetworkInfo mWiFiNetworkInfo = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
- NetworkInfo mMobileNetworkInfo = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
- if(!mWiFiNetworkInfo.isConnected()){
- Toast.makeText(tween.this, "提示:当前处于运营商网络", Toast.LENGTH_SHORT).show(); }
- Intent it = new Intent();
- it.setClass(tween.this,tabhost.class);
- startActivity(it);
- }
- else{
- Toast.makeText(tween.this, "当前网络连接不可用!", Toast.LENGTH_SHORT).show();
- }}
- }
- }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。