Android 学习(二)
今天在用service回调的时候发现的一个问题
记下来
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById(R.id.btnstartserv).setOnClickListener(this);
findViewById(R.id.btnstopserv).setOnClickListener(this);
findViewById(R.id.btnbindserv).setOnClickListener(this);
findViewById(R.id.btnubindserv).setOnClickListener(this);
i = new Intent(getApplicationContext(), MyService.class);
tv = (TextView) findViewById(R.id.show);
tv的赋值不能卸载super.onCreate之前,否则会报nullpointexception 错误。

浙公网安备 33010602011771号