android问题及解决方案,ANDROID开发之问题积累及解决方案(不断更新)
一、activity跳转及传值当进行activity之间的跳转时我们会遇到这样的问题。首先熟悉下activity之间跳转。Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据。几种跳转方式可参照Android之Activity的几种跳转方式和Activity的跳转与传值,下面来说说开发时遇到的错误。1、Internal Server error在开发工程时,
一、activity跳转及传值
当进行activity之间的跳转时我们会遇到这样的问题。首先熟悉下activity之间跳转。Activity跳转与传值,主要是通过Intent类来连接多个Activity,以及传递数据。几种跳转方式可参照Android之Activity的几种跳转方式和Activity的跳转与传值,下面来说说开发时遇到的错误。
1、Internal Server error
在开发工程时,有6个activity,又新增一个activity,这个activity有listview,目的是从这个新增的activity点击item跳转到另外的6个activity,如下代码:
public void onItemClick(AdapterView> parent, View view, int position, longid) {//这里做跳转,跳转到各自对应的页
switch(position) {case 1:
openActivity(TariffMajorGoodsListActivity.class);break;case 2:
openActivity(TariffNativeDirectoryListActivity.class);break;case 3:
openActivity(TariffTaxRateListActivity.class);break;case 4:
openActivity(TariffCommentaryListActivity.class);break;case 5:
openActivity(ClassifyDecisionListActivity.class);break;case 6:
openActivity(ClassifyAdjudicationListActivity.class);break;default:break;
}
}
protected void openActivity(Class>pClass) {
openActivity(pClass,null);
}protected void openActivity(Class>pClass, Bundle pBundle) {
Intent intent= new Intent(this, pClass);if (pBundle != null) {
intent.putExtras(pBundle);
}
startActivity(intent);
}protected voidopenActivity(String pAction) {
openActivity(pAction,null);
}protected voidopenActivity(String pAction, Bundle pBundle) {
Intent intent= newIntent(pAction);if (pBundle != null) {
intent.putExtras(pBundle);
}
startActivity(intent);
}
然而,运行程序时,程序在点击跳转时报Internal Server error错误,直译为“内部服务器错误”,所以错就在Manifest.xml了,就让我们认识下它吧AndroidManifest.xml配置文件详解 ,仔细查看Manifest.xml,确认是正确的,这就纳闷了~~哪里的错了???顺手点了根烟,边抽边想,这个调的web接口啊,或许是参数不对,抽完马上查看,果然是这里的问题,立马给它传个参数。
public void onItemClick(AdapterView> parent, View view, int position, longid) {//这里做跳转,跳转到各自对应的页
Bundle mBundle = newBundle();
Gson gson= newGson();switch(position) {case 1:
MajorGoodsEntity majorGoodsEntity= new MajorGoodsEntity(null,datatotal,null,datatotal,null, null, null, null);
mBundle.putSerializable("majorGoods", majorGoodsEntity);
openActivity(TariffMajorGoodsListActivity.class,mBundle);break;case 2:
NativeDirectoryEntity directoryEntity= new NativeDirectoryEntity(null,datatotal);
mBundle.putSerializable("nativeDirectory", directoryEntity);
openActivity(TariffNativeDirectoryListActivity.class,mBundle);break;case 3:
TariffEntity queryEntity= new TariffEntity(null, datatotal,null, null, null, null, null, null, null, null);
mBundle.putSerializable("tariffQueryEntity", gson.toJson(queryEntity,TariffEntity.class));
openActivity(TariffTaxRateListActivity.class,mBundle);break;case 4:
TariffCommentaryItemEntity commentaryItemEntity= new TariffCommentaryItemEntity(null, datatotal, null, null,null);
mBundle.putSerializable("commentaryItemEntity",commentaryItemEntity);
openActivity(TariffCommentaryListActivity.class,mBundle);break;case 5:
ClassifyPublicationEntity entity=new ClassifyPublicationEntity("D",null, datatotal, null, null,null, null, null, null);
mBundle.putSerializable("conditionJSON", gson.toJson(entity, ClassifyPublicationEntity.class));
openActivity(ClassifyDecisionListActivity.class,mBundle);break;case 6:
ClassifyPublicationEntity entitys=new ClassifyPublicationEntity("R",null,datatotal,null,null,null,null,null, null);
mBundle.putSerializable("conditionJSON", gson.toJson(entitys, ClassifyPublicationEntity.class));
openActivity(ClassifyAdjudicationListActivity.class,mBundle);break;default:break;
}
}
哈哈,这样一debug,果然调方法了,此问题完美解决。
原文:http://www.cnblogs.com/squirrel-king/p/5231057.html
更多推荐
所有评论(0)