0
我有一個我希望傳遞意圖的標籤式活動。我正在嘗試傳遞一些參數,但這並沒有通過這個意圖。我正在設置onClickListener中的當前選項卡。我的代碼在下面我怎麼做?我如何將意圖傳遞給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");
你想讓你的代碼行爲到底是什麼? – dd619
我傳遞一個字符串參數到另一個選項卡上的谷歌地圖。這是我需要在地圖上繪製的路線的名稱。 – yams
不需要通過意圖傳遞字符串。你可以聲明字符串爲靜態變量,然後在任何地方訪問 – dd619