一、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. questasim仿真控制——breakpoint断点

    在使用questasim或者modelsim仿真时,如果需要控制仿真时间长度,一般在vsim中使用 run xxxxms/us等命令. 但是有时候不好估计仿真多长时间才能得到所有希望观察的结果,这个时 ...

  2. ios调用本地拨打电话,发送短信

    电话.短信是手机的基础功能,iOS中提供了接口,让我们调用.这篇文章简单的介绍一下iOS的打电话.发短信在程序中怎么调用. 1.打电话   [[UIApplication sharedApplicat ...

  3. canvas文本自动换行

    在用canvas中写刮奖结果的时候发现canvas中的文本不会自动折行,要进行截断另起一行来写.在此参考文章html5-canvas的绘制文本自动换行来做改写. 根据canvas宽度来做折行 在此根据 ...

  4. 使用BigDecimal进行精确运算

    首先我们先来看如下代码示例: 1 public class Test_1 { 2 public static void main(String[] args) { 3 System.out.print ...

  5. 【多线程 5】线程池的类型以及submit()和execute()的区别

    就跟题目说的一样,本篇博客,本宝宝主要介绍两个方面的内容,其一:线程池的类型及其应用场景:其二:submit和execute的区别.那么需要再次重申的是,对于概念性的东西,我一般都是从网上挑选截取,再 ...

  6. 安装spf13-vim on Windows10

    安装之前 1.系统为 windows10  Version 1607 64位 企业版 2.参考 http://www.codeweblog.com/gvim-64%E4%BD%8D-windows-7 ...

  7. Life cycle of plist in Lockdown changes dramatically in iOS 10

    We could take advantage of plist to bypass Trust Relationship so as to extract data from a iDevice. ...

  8. [JS]递归对象或数组

    function recursive(obj) { var output = ''; if (typeof obj === 'object') { for (var key in obj) { var ...

  9. dos命令记录以及dos下通过进程id查找工作路径

    dos命令 tasklist |findstr "1696" 通过进程id查看进程名 tasklist 列出所有进程 netstat -ano 查看当前网络通信进程连接的各种状态 ...

  10. Tomcat和JavaWeb笔记

    <iframe src="http://www.xmind.net/embed/XFXh" width="900px" height="540p ...