我有一个要传递意图的选项卡式活动。我正在尝试传递一些参数,但这并没有传递意图。我在 onClickListener 中设置当前选项卡。我的代码在下面我该怎么做?
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("InlinedApi")
private void displayEvacRouteTable(){
AsyncClass ac = new AsyncClass(EvacRouteTableActivity.this);
ac.execute();
List<String> evacRouteList = new ArrayList<String>(DALController.sharedInstance().getAllRouteNames());
// get a reference for the TableLayout
TableLayout ll = (TableLayout) findViewById(R.id.TableLayout01);
for (String routeName : evacRouteList){
// create a new TableRow
TableRow row = new TableRow(this);
// create a new TextView
TextView destNameTextView = new TextView(this);
String evacRouteName = " " + routeName;
SpannableString evacRouteSpanString = new SpannableString(evacRouteName);
evacRouteSpanString.setSpan(new UnderlineSpan(), 0, evacRouteName.length(), 0);
destNameTextView.setText(evacRouteSpanString);
destNameTextView.setTextColor(Color.BLUE);
destNameTextView.setTextSize(20);
destNameTextView.setHeight(55);
Linkify.addLinks(evacRouteSpanString, Linkify.ALL);
final Intent i = new Intent(EvacRouteTableActivity.this, MapViewActivity.class);
Bundle b = new Bundle();
b.putString("evacObject", routeName);
i.putExtras(b);
destNameTextView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AsyncClass ac = new AsyncClass(EvacRouteTableActivity.this);
ac.execute();
@SuppressWarnings("deprecation")
TabActivity ta = (TabActivity) EvacRouteTableActivity.this.getParent();
ta.getTabHost().setCurrentTab(4);
}
});
destNameTextView.setBackgroundResource(R.drawable.cell_shape);
destNameTextView.setLayoutParams(new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
row.addView(destNameTextView);
ll.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
}
这是我试图用来接收意图的代码:
String fuelStopBundle = getIntent().getExtras();
if (fuelStopBundle != null){
evacName = fuelStopBundle.getString("evacObject");