一直忙于找招聘会,宣讲会,好久都没有学Android了。现在回顾,不知道自己有没有这个能力,不过,尽力而为吧,脑子转不快,可是,我勤于去学就好
1、一直没开Eclipse,后来新建一个项目,出现了一些问题,Error generating final archive,原因是:android要求所有的程序必须有签名,否则就不会安装该程序。在我们开发过程中,adt使用debug keystore,在 preference->android->buid中设置。debug的keystore默认有效期为一年,如果你是从一年前开始完android程序,那么在一年后导入这个app的时候很可能出现debug keystore过期,导致你无法生成 apk文件。此时你只要删除debug keystore就行,系统又会为你生成有效期为一年的私钥。 解决方法:进入C:\Documents and Settings\Administrator\.android 删除路径下的debug.keystore及 ddms.cfg。(不同环境下的目录可能略有不同,可在eclipse中查找此路径:Window->Preferences->Android->Build下 Default debug keystore)然后重新导入即可。
2、关于控件(以button为例)的监听器
方案一:
1)
private Button startService = null;
2)
startService = (Button)findViewById(R.id.startService);
startService.setOnClickListener(new StartServicLisener());
3)创建这个StartServiceListener的类,(仍然在这个Activity里,一个内部类)
class StartServicLisener implements OnClickListener{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(TestActivity.this,FirstService.class);
startService(intent);
}
}
方案二:
1)
public Button startService=null;
2)
startService = (Button)findViewById(R.id.startService);
startService.setOnClickListener(new StartServicLisener());
3)
Button.OnClickListener StartServicLisener= new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setClass(TestActivity.this,FirstService.class);
startService(intent); };