一、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. JS实现无缝滚动

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  2. C#调用C++编写的DLL函数, 以及各种类型的参数传递 (转载)

        C#调用C++编写的DLL函数, 以及各种类型的参数传递 1. 如果函数只有传入参数,比如: C/C++ Code Copy Code To Clipboard //C++中的输出函数 int ...

  3. Sequelize 关系模型简介

    Sequelize 关系模型简介 先介绍一下本文用到的术语: 源: 调用 sequelize 中关系方法的调用者 目标: 调用 sequelize 中关系方法中的参数 比如, User.hasOne( ...

  4. js中js数组、对象与json之间的转换

    在数据传输过程中,json是以文本,即字符串的形式传递的,而JS操作的是JSON对象,所以,JSON对象和JSON字符串之间的相互转换是关键.例如:JSON字符串:var str1 = '{ &quo ...

  5. J2EE应用监控后台执行SQL

    我们可能已经很熟悉在未使用数据库连接池的hibernate的环境下,配置p6spy和sql profiler.这在单独使用hibernate,以及项目初期是有效的.但是,在真实的开发环境下,往往是项目 ...

  6. MAXIMO-数据库配置属性数据类型解释

    ALN:       字母数字字符,混合大小写,最大长度取决于数据库     Oracle = 4000 个字符     Sql Server = 8000 个字符     DB2 = 32672 个 ...

  7. 9、SQL Server 操作数据

    插入数据 使用Insert Into 插入 if(exists(select * from sys.databases where name = 'webDB')) drop database web ...

  8. Android四大组件及activity的四大启动模式

    Android四大组件 1. 广播接收者的两种类型: (1)系统广播接收者,就是继承BroadcastReceiver这个类,然后还要在清单文件中注册,注册之后给他一个action.当系统发生了这个a ...

  9. editplus工具支持sql高亮提示

    editplus默认不识别sql关键件,添加文件使其对sql高亮提示. 首先就是要自己编写一段代码,存为.stx 文件(例如sql.stx) 然后在editplus的菜单栏 工具-> 配置用户工 ...

  10. SQL 字符串处理大全

    select语句中只能使用sql函数对字段进行操作(链接sql server),select 字段1 from 表1 where 字段1.IndexOf("云")=1;这条语句不对 ...