public Barint x int y int w int
檔板控制 � � � � � public Bar(int x, int y, int w, int h, int cc) { this. x = x; this. y = y ; this. w = w; this. h = h; this. color = cc; } // public void move. Left() { x -= 5; if (x < 0) x = 0; } public void move. Right() { x += 5; if (x+w > view. Width) x = view. Width - w; } public void move. Center. To. Pos( int pos) { this. x = pos - w/2;
加入音樂 � mp. set. Data. Source("/sdcard/a. mp 3"); � //mp. set. On. Completion. Listener(new On. Completion. Listener() { // //@Override //public void on. Completion(Media. Player mp) { //// TODO Auto-generated method stub //mp. release(); //} // //}); mp. prepare(); } catch (Illegal. Argument. Exception e) { } catch (Illegal. State. Exception e) { } catch (IOException e) { } mp. start(); � � � �
音樂中途停止再繼續播放 � � � � � � � protected void on. Pause() { // TODO Auto-generated method stub super. on. Pause(); mp. pause(); } @Override protected void on. Restart() { // TODO Auto-generated method stub super. on. Restart(); try { mp. prepare(); } catch (Illegal. State. Exception e) { // TODO Auto-generated catch block e. print. Stack. Trace(); } catch (IOException e) { // TODO Auto-generated catch block e. print. Stack. Trace(); } mp. start(); } @Override protected void on. Stop() { // TODO Auto-generated method stub super. on. Stop(); mp. stop(); }
參考文獻 � 網路程式設計(上課教材) � Android編成 http: //androidbiancheng. blogspot. tw/2009/12/ blog-post. html
- Slides: 12