0

フラグメントのアクティビティページから新しいアクティビティページに整数値のバンドルを渡そうとしています。ただし、整数は渡されていないようであるため、その値は常に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です。これは間違った方法ですか?

4

0 に答える 0