馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
本帖最後由 f9999200 於 2012-8-3 12:53 編輯
1. 我的第一頁是 由spinner選擇之後,再傳值進去到別頁
2. spinner選擇之後的頁面是 由 TAB 跟 FrameLayout 所結合的頁面
3. TAB 有 三個activity(都是FrameLayout) 分別是 "地圖" "資訊" "交通"
當我從第一頁的spinner選擇之後,會傳不同的值給這三個activity,
如果當我選擇之後,個別啟動這三個ACTIVITY 是可以成功的
但是,跳到TAB 頁面 就會發生錯誤,是不是哪裡有錯誤呢?
請各位大大救救我吧~~
這是spinner傳值的代碼:
- intent.setClass(taipeicity.this, market.class);
- intent2.setClass(taipeicity.this, market_info.class);
- intent3.setClass(taipeicity.this, market_map.class);
- //傳遞資料給Activity-------------
- bundle.putString("strCnametxt", Cnametxt);
- bundle.putString("strEnametxt", Enametxt);
- bundle.putString("strTimetxt", Timetxt);
- bundle.putString("strIfotxt", Ifotxt);
- bundle.putString("strAddresstxt", Addresstxt);
- bundle.putString("srtPictxt", Pictxt);
- intent2.putExtras(bundle);
- intent3.putExtras(bundle);
- startActivity(intent);
複製代碼 這個是,TAB的代碼:-
- //TAB按鈕
- Resources res = getResources(); // Resource object to get Drawables
- TabHost tabHost = getTabHost(); // The activity TabHost
- TabHost.TabSpec spec; // Resusable TabSpec for each tab
- Intent intent; // Reusable Intent for each tab
-
-
- //地圖
- intent = new Intent().setClass(this, market_map.class);
- spec = tabHost.newTabSpec("map").setIndicator("",
- res.getDrawable(R.drawable.ic_map))
- .setContent(intent);
- tabHost.addTab(spec);
- //資訊
- intent = new Intent().setClass(this, info.class);
- spec = tabHost.newTabSpec("albums").setIndicator("",
- res.getDrawable(R.drawable.ic_v_inf))
- .setContent(intent);
- tabHost.addTab(spec);
-
- //交通
- intent = new Intent().setClass(this, traffic.class);
- spec = tabHost.newTabSpec("songs").setIndicator("",
- res.getDrawable(R.drawable.ic_t_inf))
- .setContent(intent);
- tabHost.addTab(spec);
-
- tabHost.setCurrentTab(0);
複製代碼 這是,"資訊"接受傳值的代碼:- // 接受SpinnerBundle傳來的值
- Bundle bundle=this.getIntent().getExtras();
-
- String StrEnametxt=bundle.getString("strEnametxt");
- String StrTimetxt=bundle.getString("strTimetxt");
- String StrIfotxt=bundle.getString("strIfotxt");
- String StrAddresstxt=bundle.getString("strAddresstxt");
-
-
-
- TextView Enametxt=(TextView) findViewById(R.id.Enametxt);
- TextView Timetxt=(TextView) findViewById(R.id.Timetxt);
- TextView Ifotxt=(TextView) findViewById(R.id.Ifotxt);
- TextView Addresstxt=(TextView) findViewById(R.id.Addresstxt);
-
-
- Enametxt.setText(StrEnametxt);
- Timetxt.setText(StrTimetxt);
- Ifotxt.setText(StrIfotxt);
- Addresstxt.setText(StrAddresstxt);
-
複製代碼 ==========================================================
解決的方法:
先在 spinner選擇之後的頁面 先做一個 Bundle的接收
然後 同一個頁面 寫 Bundle2 傳送
最後再 "資訊" 的 ACTIVITY 接收 Bundle2 的資訊
不知道這樣解決的方法合不合理......這是我剛剛突然想到的 |

|