public class MainActivity extends ActionBarActivity {
	private TextView textView;
	private int i=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView=(TextView) findViewById(R.id.textView1);
        final Handler handler=new Handler(){
        	public void handleMessage(android.os.Message msg) {
        		Bundle bundle=msg.getData();
        		String string=bundle.getString("name");
        		textView.setText(string);
        	};
        };
        Timer timer=new Timer();
        timer.schedule(new TimerTask() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				Message message=new Message();
				Bundle bundle =new Bundle();
				bundle.putString("name", "Hello"+i);
				i++;
				message.setData(bundle);
				handler.sendMessage(message);
			}
		}, 1000,1000);
        
        
    }
}

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

 

相关文章:

  • 2021-04-19
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-04-14
  • 2022-02-08
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
相关资源
相似解决方案