2017-06-04 53 views

回答

0

您可以使用處理程序顯示此類數據。我給你看一個示例代碼..

public class MainActivity extends AppCompatActivity { 

Handler starter, repeater; 
Runnable r = new Runnable() { 
    @Override 
    public void run() { 
     //Do whatever in this space it will loop until the app pauses and resume when app resume 
     // and update this space at an interval of one minute 

     repeater.postDelayed(this, 60000); 
    } 
}; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 


} 

@Override 
protected void onResume() { 
    super.onResume(); 
    starter = new Handler(); 
    repeater = new Handler(); 
    starter.post(r); 
} 

@Override 
protected void onPause() { 
    repeater.removeCallbacks(r); 
    super.onPause(); 
} 
}