一、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, long id) {
//这里做跳转,跳转到各自对应的页
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 void openActivity(String pAction) {
openActivity(pAction, null);
} protected void openActivity(String pAction, Bundle pBundle) {
Intent intent = new Intent(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, long id) {
//这里做跳转,跳转到各自对应的页
Bundle mBundle = new Bundle();
Gson gson = new Gson();
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,果然调方法了,此问题完美解决。

ANDROID开发之问题积累及解决方案(一)的更多相关文章

  1. ANDROID开发之问题积累及解决方案(二)

    错误:“Binary XML file line # : Error inflating class” 原因:此异常是布局文件中有错引起的,那么返回到布局文件中看看. <?xml version ...

  2. ANDROID开发之问题积累及解决方案(三)

    1.dexDebug ExecException finished with non-zero exit value 2需要在gradle中配置下面的代码,原因是引用了多个libraries文件 de ...

  3. ANDROID开发之问题积累及解决方案(四)

    首先贴出问题类型: 程序无法启动,查看logcat,提示如下信息: W/dalvikvm(679): PR_CAPBSET_DROP 32 failed: Invalid argument. Plea ...

  4. Android 开发有用代码积累

    Android开发需求变化快,开发周期要求尽量短,接下来一系列文章从实际使用出发总结一些常用的代码片段,便于查找,也为后来人提供一份参考. 1.获取Manifest的基本信息(升级页面和软件关于页面一 ...

  5. 9种常见的Android开发错误及解决方案

    整理总结了9个Android开发中的错误以及解决方案,共同探讨进步! 1. 如果你的项目的R文件不见的话,可以试下改版本号在保存,R文件不见一般都是布局文本出错导致. 2. 布局文件不可以有大写字母 ...

  6. Android开发——Android M(6.0) 权限解决方案

    Android开发--Android M(6.0) 权限解决方案 自从Android M(6.0)发布以来,权限管理相比以前有了很大的改变,很多程序员发现之前运行的好好的Android应用在Andro ...

  7. Android 开发日常积累

    Android 集合 Android 开源项目分类汇总 扔物线的 HenCoder 高级 Android 教程 hencoder HenCoder:给高级 Android 工程师的进阶手册 Andro ...

  8. Android开发——View滑动冲突解决方案

    0. 前言   我们在Android开发--事件分发机制详解中深入学习了事件分发机制,为我们解决Android开发中的滑动冲突问题做了初步准备.针对滑动冲突这里给出两种解决方案:外部拦截法和内部拦截法 ...

  9. Android开发——常见的内存泄漏以及解决方案(二)

    )Android2.3以后,SoftReference不再可靠.垃圾回收期更容易回收它,不再是内存不足时才回收软引用.那么缓存机制便失去了意义.Google官方建议使用LruCache作为缓存的集合类 ...

随机推荐

  1. Codeforces Round #232 (Div. 2) D. On Sum of Fractions

    D. On Sum of Fractions Let's assume that v(n) is the largest prime number, that does not exceed n; u ...

  2. 慕课网-Java入门第一季-6-10 练习题

    来源:http://www.imooc.com/ceping/1596 以下关于二维数组的定义和访问正确的是() A int[ ][ ] num = new int[ ][ ]; B int[ ][ ...

  3. Xcode7打包,iOS9真机闪退,如何解决?

    问:有些项目用xcode7打开运行,打包安装到iOS9设备上程序会闪退. 如果用xcode7以下编译,然后打包到iOS9的设备上就是正常的.这是为什么,关键是,怎么解决? 答:iOS9发布之后,有些a ...

  4. lintcode-【中等】恢复IP地址

    题目 给一个由数字组成的字符串.求出其可能恢复为的所有IP地址.链接. 样例 给出字符串 "25525511135",所有可能的IP地址为: [ "255.255.11. ...

  5. RBAC在thinkphp中有Auth类 可以很好的实现权限控制

    import('ORG.Util.Auth');//加载类库 $auth=new Auth(); if($auth->check('show_button',1)){// 第一个参数是规则名称, ...

  6. 浅谈Web缓存

    在前端开发中性能一直都是被大家所重视的一点,然后判断一个网站的性能最直观的就是看网页打开的速度. 其中提高网页反应的速度的一个方式就是使用缓存.一个优秀的缓存策略可以缩短网页请求资源的距离,减少延迟, ...

  7. StrangeIoc框架学习----在项目中实战

    最近,因为公司的项目一直在研究StrangeIoc框架,小有所得,略作记录. StrangeIoc是一款基于MVCS的一种框架,是对MVC思想的扩展,是专门针对unity开发的一款框架,非常好用. 一 ...

  8. springboot一个service内组件的加载顺序

    先加载自身构造器,所以在构造器中初始化时若使用需要注入的(即@Autowired注解的)组件相关的方法,则会报null: 然后加载注入的组件即@Autowired 最后加载@PostConstruct ...

  9. etc 安装及使用

    键值存储仓库,用于配置共享和服务发现. A highly-available key value store for shared configuration and service discover ...

  10. 阿里云slb和ucloud负载均衡ulb添加ssl证书将http服务https化的配置详解

    阿里云和ucloud服务器配置ssl证书将http服务https化的配置详解 项目背景: 苹果App于2017年1月1日将启用App Transport Security安全功能,即强制App通过HT ...