the import android.os.Handler conflicts with a type defined in the same file packagepackage test.com;import android.app.Activity;import android.os.Bundle; import android.os.Handler;//这里不行import android.view.View;import android.view.View.OnCli
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/18 23:40:46
the import android.os.Handler conflicts with a type defined in the same file packagepackage test.com;import android.app.Activity;import android.os.Bundle; import android.os.Handler;//这里不行import android.view.View;import android.view.View.OnCli
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);
}
};
}
the import android.os.Handler conflicts with a type defined in the same file packagepackage test.com;import android.app.Activity;import android.os.Bundle; import android.os.Handler;//这里不行import android.view.View;import android.view.View.OnCli
...你定义一个和android Handler同名的类干嘛?
你定义的类换个名字就OK