編輯:關於Android編程
final Handler myHandler = new Handler () { @Override public void handleMessage(Message msg) { if (msg.what == 0x1222) { } } };------------------------------------------------------------------------------------------------
new Timer().schedule( new TimerTask(){ //TimerTask類型的對象,TimerTask的run()方法是要周期執行的一個任務 @Override public void run() { currentColor ++; if (currentColor >= 6) currentColor = 0; Message m = new Message(); m. what = 0x1122; handler.sendMessage(m); } }, 0 , //表示多長時間後開始執行 100//執行的周期 );【example】 霓虹燈:
public class FrameLayoutTest extends Activity { private int currentColor = 0; final int[] colors = new int[] { R.color.color7, R.color.color6, R.color.color5, R.color.color4, R.color.color3, R.color.color2, R.color.color1, }; final int[] names = new int[] { R.id.View01, R.id.View02, R.id.View03, R.id.View04, R.id.View05, R.id.View06, R.id.View07 }; TextView[] views = new TextView[7]; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); for (int i = 0 ; i < 7 ; i++) { views[i] = (TextView)findViewById(names[i]); } final Handler handler = new Handler() { @Override public void handleMessage(Message msg) { if(msg.what == 0x1122) { for(int i = 0 ; i < 7 - currentColor ; i++) { views[i].setBackgroundResource(colors[i + currentColor]); } for(int i = 7 - currentColor , j = 0 ; i < 7 ; i++ ,j++) { views[i].setBackgroundResource(colors[j]); } } } }; new Timer().schedule(new TimerTask() { @Override public void run() { currentColor++; if(currentColor >= 6) { currentColor = 0; } Message m = new Message(); m.what = 0x1122; handler.sendMessage(m); } }, 0 , 100); } }
public class HandlerTest extends Activity { int[] imageIds = new int[] { R.drawable.haed_danya, R.drawable.haed_fanse, R.drawable.haed_fugu, R.drawable.haed_gudian, R.drawable.haed_houqingchu }; int currentImageId = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView show = (ImageView)findViewById(R.id.show); final Handler myHandler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 0x1222) { show.setImageResource(imageIds[currentImageId++]); if (currentImageId >= 4) { currentImageId = 0; } } } }; new Timer().schedule(new TimerTask() { @Override public void run() { Message msg = new Message(); msg.what = 0x1222; myHandler.sendMessage(msg); } }, 0 , 100); } }
第8節 橫屏的播放界面在設備旋轉成橫屏的時候,視頻將自動進行全屏播放。8.1 播放器橫屏布局我們要為全屏播放界面設置一個新的布局,這個布局裡面只用來播放視頻,不需要顯示任
時間過得很快,明天終於可以拿到房子了,交完這次房租,也可以成為房東了,看看博客也好久沒有更新了,最近一直在整機器人,也沒有太多時間整理博客。今天下午和同事一起遇到了一個問
一、基本知識點1、Intent intent = new Intent();//打開浏覽器的intent.setAction(Intent.ACTION_VIEW);in
Linux內核啟動之後就到Android Init進程,進而啟動Android相關的服務和應用。啟動的過程如下圖所示: 下面將從Android4.0源碼中,和