一、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. 区分LocalStorage和偏好数据

    偏好数据类似于web.config或者session,cookie之类的值,一般用于保存一些状态值,不推荐大量的数据通过此方式存储 Local Storage不仅可以寸字符串,还可以寸JSON对象

  2. C语言获得文件一行

    C语言获得一行的数据还是比较麻烦的,这里讲一下几种曾经用过的方法. 第一种,是最笨的方法,就是一个一个字符的读取,也是最容易想到的方法.具体实现如下:void   read_line(char   l ...

  3. php服务生成exe附件下载

    <?php $realname = "zhuast.exe"; //原始文件名 $filename = "中文 文件名.exe"; //下载到浏览器的文件 ...

  4. messagePaneHost

    Microsoft.Dynamics.Framework.UI.WinForms.Controls.MessageBarType messageBarType; super(); imageList ...

  5. 用systemd脚本自动启动node js程序

    vi /usr/lib/systemd/system/pano.service [Unit] Description=pano - main site of site_name.com Documen ...

  6. MongoDB(八)Mongodb——GridFS存储

    mongoDB的文档以BSON格式存储,支持二进制的数据类型,当我们把二进制格式的数据直接保存到mongoDB的文档中.但是当文件太大时,例如图片和视频等文件,每个文档的长度是有限的,于是mongoD ...

  7. background-size拉伸背景图片

    在制作页面中常需要对背景图片在容器中进行平铺,可用background-size属性对背景编辑:拉伸,压缩等~ background-size:contain; 将背景扩展到整个容器大小. 较为实用的 ...

  8. android开发--sqlite数据库

    一.SQLite简介 Google为Andriod的较大的数据处理提供了SQLite,他在数据存储.管理.维护等各方面都相当出色,功能也非常的强大.SQLite具备下列特点: 1.轻量级 使用 SQL ...

  9. dump 分析模式之 INCORRECT STACK TRACE - djm2005dy的专栏 - 博客频道 - CSDN.NET

    Dump 分析模式之 INCORRECT STACK TRACE dump 分析模式之 INCORRECT STACK TRACE 翻译自 MDA-Anthology Page288  初学者常犯的错 ...

  10. Support Vector Machine (2) : Sequential Minimal Optimization

    目录 Support Vector Machine (1) : 简单SVM原理 Support Vector Machine (2) : Sequential Minimal Optimization ...