当前位置: 编程技术>移动开发
本页文章导读:
▪JDepend运用小记 JDepend使用小记
http://blog.csdn.net/zhengsj/article/details/4148117
......
▪ handler 计时器处置 handler 计时器处理
我觉得很好用,控制计时并且实现两个Activity 之间跳转,这里传参数用了bundle 传递:package com.face;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import andr.........
▪ Box2D v2.2.0 User Manual中文版(一) Box2D v2.2.0 User Manual中文版(1)
详情请参考:【Software Myzone】:http://www.firedragonpzy.com.cn/index.php/archives/2362
......
[1]JDepend运用小记
来源: 互联网 发布时间: 2014-02-18
JDepend使用小记
http://blog.csdn.net/zhengsj/article/details/4148117
http://blog.csdn.net/zhengsj/article/details/4148117
[2] handler 计时器处置
来源: 互联网 发布时间: 2014-02-18
handler 计时器处理
我觉得很好用,控制计时并且实现两个Activity 之间跳转,这里传参数用了bundle 传递:
package com.face;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;
public class Activity9 extends Activity {
private MyHandler myHandler;
myThread mythread = null;
private boolean bool = true;
private int count = 0;
int type = 0;
int time = 0;
int ctime = 0;
TextView tm;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test9);
tm = (TextView) findViewById(R.id.tsTxt);
bool = true;
myHandler = new MyHandler(Looper.getMainLooper());
mythread = new myThread();
mythread.start();
}
class myThread extends Thread {
@Override
public void run()
{
while (bool)
{
Message message = myHandler.obtainMessage();
message.what = 1;
myHandler.sendMessage(message);
try
{
Thread.sleep(5000);// 休息1min
count += 5;
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
class MyHandler extends Handler {
public MyHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg)
{
if (msg.what == 1)
{
if (count == (ctime + time))
{
count = 0;
}
tm.setText("====main======" + count);
if (count == 20)
{
ctime = count;
Log.i("main", "====="+count);
otherActivity();
}
}
}
}
public void otherActivity()
{
time = 4 * 15;
Intent itent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("showtype", "" + time);
itent.putExtras(bundle);
itent.setClass(Activity9.this, Activity12.class);
startActivity(itent);
}
@Override
protected void onDestroy()
{
bool = false;
myHandler.removeCallbacks(mythread);
super.onDestroy();
}
}
--------------------------
package com.face;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;
public class Activity12 extends Activity {
TextView timeTxt = null;
private CollectHandler myHandler;
CollectThread mythread = null;
private boolean bool = true;
private int count = 0;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test12);
timeTxt = (TextView) findViewById(R.id.tmTxt);
Intent intent = this.getIntent();
String s = intent.getExtras().getString("showtype");
if (s != null)
{
int opentime = Integer.parseInt(s);
if (opentime > 0)
{
count = opentime;
bool = true;
myHandler = new CollectHandler(Looper.getMainLooper());
mythread = new CollectThread();
mythread.start();
} else
{
startActivity(new Intent(Activity12.this, Activity9.class));
finish();
}
} else
{
Log.i("Activity12", "====null");
finish();
}
}
class CollectThread extends Thread {
@Override
public void run()
{
while (bool)
{
Message message = myHandler.obtainMessage();
message.what = 1;
myHandler.sendMessage(message);
try
{
Thread.sleep(5000);// 休息1min
count -= 5;
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
class CollectHandler extends Handler {
public CollectHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg)
{
if (msg.what == 1)
{
if (count > 0)
{
timeTxt.setText("======Activity12===" + count);
} else
{
//startActivity(new Intent(Activity12.this, Activity9.class));
finish();
}
}
}
}
@Override
protected void onDestroy()
{
bool = false;
myHandler.removeCallbacks(mythread);
super.onDestroy();
}
}
我觉得很好用,控制计时并且实现两个Activity 之间跳转,这里传参数用了bundle 传递:
package com.face;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;
public class Activity9 extends Activity {
private MyHandler myHandler;
myThread mythread = null;
private boolean bool = true;
private int count = 0;
int type = 0;
int time = 0;
int ctime = 0;
TextView tm;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test9);
tm = (TextView) findViewById(R.id.tsTxt);
bool = true;
myHandler = new MyHandler(Looper.getMainLooper());
mythread = new myThread();
mythread.start();
}
class myThread extends Thread {
@Override
public void run()
{
while (bool)
{
Message message = myHandler.obtainMessage();
message.what = 1;
myHandler.sendMessage(message);
try
{
Thread.sleep(5000);// 休息1min
count += 5;
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
class MyHandler extends Handler {
public MyHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg)
{
if (msg.what == 1)
{
if (count == (ctime + time))
{
count = 0;
}
tm.setText("====main======" + count);
if (count == 20)
{
ctime = count;
Log.i("main", "====="+count);
otherActivity();
}
}
}
}
public void otherActivity()
{
time = 4 * 15;
Intent itent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("showtype", "" + time);
itent.putExtras(bundle);
itent.setClass(Activity9.this, Activity12.class);
startActivity(itent);
}
@Override
protected void onDestroy()
{
bool = false;
myHandler.removeCallbacks(mythread);
super.onDestroy();
}
}
--------------------------
package com.face;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.TextView;
public class Activity12 extends Activity {
TextView timeTxt = null;
private CollectHandler myHandler;
CollectThread mythread = null;
private boolean bool = true;
private int count = 0;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.test12);
timeTxt = (TextView) findViewById(R.id.tmTxt);
Intent intent = this.getIntent();
String s = intent.getExtras().getString("showtype");
if (s != null)
{
int opentime = Integer.parseInt(s);
if (opentime > 0)
{
count = opentime;
bool = true;
myHandler = new CollectHandler(Looper.getMainLooper());
mythread = new CollectThread();
mythread.start();
} else
{
startActivity(new Intent(Activity12.this, Activity9.class));
finish();
}
} else
{
Log.i("Activity12", "====null");
finish();
}
}
class CollectThread extends Thread {
@Override
public void run()
{
while (bool)
{
Message message = myHandler.obtainMessage();
message.what = 1;
myHandler.sendMessage(message);
try
{
Thread.sleep(5000);// 休息1min
count -= 5;
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
}
}
class CollectHandler extends Handler {
public CollectHandler(Looper looper) {
super(looper);
}
@Override
public void handleMessage(Message msg)
{
if (msg.what == 1)
{
if (count > 0)
{
timeTxt.setText("======Activity12===" + count);
} else
{
//startActivity(new Intent(Activity12.this, Activity9.class));
finish();
}
}
}
}
@Override
protected void onDestroy()
{
bool = false;
myHandler.removeCallbacks(mythread);
super.onDestroy();
}
}
[3] Box2D v2.2.0 User Manual中文版(一)
来源: 互联网 发布时间: 2014-02-18
Box2D v2.2.0 User Manual中文版(1)
详情请参考:【Software Myzone】:http://www.firedragonpzy.com.cn/index.php/archives/2362
详情请参考:【Software Myzone】:http://www.firedragonpzy.com.cn/index.php/archives/2362
最新技术文章: