如何将参数传递到与标签主机的新活动 [英] How to pass a parameter to a new activity with tab host

查看:122
本文介绍了如何将参数传递到与标签主机的新活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Android的主机选项卡将参数传递到一个新的活动,但它显示一个非法例外

I am passing a parameter to a new activity using tab host in android but it is showing an illegal exception

 Intent homeintent;   
 // Create an Intent to launch an Activity for the tab (to be reused) 
 homeintent = new Intent();
 Bundle bundle=getIntent().getExtras();
 String strusername=bundle.get("strUserName").toString();
 String strPassWord=bundle.getString("strPassword").toString();
 String questGroupId=bundle.getString("questGroupId").toString();
 homeintent.putExtra("strUserName", strusername);
 homeintent.putExtra("strPassword",strPassWord );
 homeintent.putExtra("questGroupId",questGroupId);
 homeintent.setClass(this, HomeActivity.class); 
 spec = tabHost.newTabSpec("home").setIndicator("Home",res.getDrawable(R.drawable.home_tab_bar_icon)).setContent(homeintent);
 tabHost.addTab(spec); 

任何人能告诉我如何在通过使用Android的意图与tabhost参数?

Can anybody tell me how to pass a parameter using intent with tabhost in android?

推荐答案

您使用的是正确的方式......给这个一将数据放入之前试用意向setClass太..。

You are using the right way... Give this a try too.. setClass of Intent before putting Data into it.

这篇关于如何将参数传递到与标签主机的新活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆