你好我是这个网站的新手也有点新的android编程...android bundle不会继续
每次我点击按钮去下一个活动,我得到一个力量关闭。我知道这个活动是有效的,因为我评论了捆绑包..任何人都知道我做错了什么?
// click button on 1st activity
Intent iCreate = new
Intent("silver.asw.charactersheet.CREATECHARACTER");
iCreate.putExtra("cname",item);
startActivity(iCreate);
// on item select
item = spin.getItemAtPosition(position).toString();
// spinner is being populated by sql database
// 2nd activity
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.character);
TextView character = (TextView)findViewById(R.id.tvViewCharacter);
Bundle b = this.getIntent().getExtras();
String item = b.getString("cname");
character.setText(item);
}
另外,我没有任何警告或不能检查我的logcat,因为我使用的是一个Android应用程序ide的AIDE。 (之前,我离开了家,同样的问题我已经测试此代码在我的电脑上。)
当你做到这一点'项目= spin.getItemAtPosition(位置)的ToString( );'? 'startActivity(iCreate)之前或之后;'? – candyleung 2012-04-26 03:06:27
之后,在上面选择的方法 – SilverWolfe 2012-04-26 03:31:29
我不知道,看来你正在为'String item = b.getString(“cname”);''获取'null'。当'iCreate.putExtra(“cname”,item);''时你检查过'item'的值吗? – candyleung 2012-04-26 03:37:28