【问题标题】:How to pass a parameter to a new activity with tab host如何使用选项卡主机将参数传递给新活动
【发布时间】:2014-05-20 17:31:26
【问题描述】:

我正在使用 android 中的选项卡主机将参数传递给新活动,但它显示非法异常

 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中使用intent和tabhost传递参数?

【问题讨论】:

    标签: android


    【解决方案1】:

    您使用的是正确的方法...也可以尝试一下...在将 Data 放入之前 setClass of Intent。

    【讨论】:

      猜你喜欢
      • 2020-05-10
      • 1970-01-01
      • 2011-10-12
      • 2014-10-30
      • 2013-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-15
      相关资源
      最近更新 更多