我正在尝试将带有整数值的包从片段“活动”页面传递到新的活动页面。但是,似乎没有传递整数,因此它的值始终为0.导致此问题的原因是什么?我错过了什么吗?
这是片段活动:
public class TravelogueSEOPageFragment extends SherlockFragment {
//method here that creates the bundle to be passed on to the new activity
public void Map(View v){
Intent offlineMapView = new Intent(v.getContext(), TOfflineMapView.class);
Bundle b = new Bundle();
b.putInt("id", travelogueID);
offlineMapView.putExtras(b);
startActivity(offlineMapView);
}
}
这是新的Activity类:
public class TOfflineMapView extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle b = getIntent().getExtras();
int tID = b.getInt("id");
...//remove unnecessary codes
}
}
所以我的tID永远是0.这是错误的方法吗?