the import android.os.Handler conflicts with a type defined
来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/06/23 05:12:22
the import android.os.Handler conflicts with a type defined in the same file package
package test.com;import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;//这里不行
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Handler extends Activity { /** Called when the activity is first created.*/
private Button startButton = null;
private Button endButton = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startButton = (Button)findViewById(R.id.startButton);
endButton = (Button)findViewById(R.id.endButton);
startButton.setOnClickListener(new StartButtonListener());
endButton.setOnClickListener(new EndButtonListener());
}
class StartButtonListener implements OnClickListener{
@Override public void onClick(View v) {
// TODO Auto-generated method stub
handler.post(updateThread);
}
}
class EndButtonListener implements OnClickListener{
@Override public void onClick(View v) {
// TODO Auto-generated method stub
handler.removeCallbacks(updateThread);
}
}
Handler handler = new Handler();
Runnable updateThread = new Runnable(){
@Override public void run() {
// TODO Auto-generated method stub
System.out.println("UpdateThread");
handler.postDelayed(updateThread,3000);
}
};
}
package test.com;import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;//这里不行
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Handler extends Activity { /** Called when the activity is first created.*/
private Button startButton = null;
private Button endButton = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
startButton = (Button)findViewById(R.id.startButton);
endButton = (Button)findViewById(R.id.endButton);
startButton.setOnClickListener(new StartButtonListener());
endButton.setOnClickListener(new EndButtonListener());
}
class StartButtonListener implements OnClickListener{
@Override public void onClick(View v) {
// TODO Auto-generated method stub
handler.post(updateThread);
}
}
class EndButtonListener implements OnClickListener{
@Override public void onClick(View v) {
// TODO Auto-generated method stub
handler.removeCallbacks(updateThread);
}
}
Handler handler = new Handler();
Runnable updateThread = new Runnable(){
@Override public void run() {
// TODO Auto-generated method stub
System.out.println("UpdateThread");
handler.postDelayed(updateThread,3000);
}
};
}
...你定义一个和android Handler同名的类干嘛?
你定义的类换个名字就OK
你定义的类换个名字就OK
Android import问题
android求助The method of type must override a superclass metho
There is no result type defined for type 'input' mapped with
There is no result type defined for type 'json' mapped with
the conflicts management翻译.
Android os 中文的翻译是什么?
import android.content.content;什么意思啊
android The method getText() is undefined for the type R.str
英语翻译a foreign trade corporation with import-export operation
Mr.White works with a chemicals import & export company ,but
程序Android中Handler和Timer还有Thread的最大区别是什么?
英语翻译Green tea is a type of tea made solely with the leaves o