[J2SE] android menu 資料連結問題?

看板java作者 (PHILLU)時間15年前 (2009/04/02 01:21), 編輯推噓2(202)
留言4則, 2人參與, 最新討論串1/2 (看更多)
各位大大好 小弟我 目前在寫android 的應用程式 目前遇到了一個問題 因為我要運用 下面一個類別的變數 該如何把 menu 與 下面一個類別做連結呢? 謝謝 我是用Eclipse 的 public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()){ case 1: onLocationChanged(Location loc);-------> X 顯示錯誤 int s= 5; -------->示意 return true; case 2: onLocationChanged(Location loc);-------------------->X 顯示錯誤 int s= 10; ------> 示意 return true; } return true; } public class MyLocationListener implements LocationListener { public void onLocationChanged(Location loc) { if (loc != null) { //show location in TextView TextView TV =(TextView)findViewById(R.id.latlon); String strlat = Double.toString(loc.getLatitude()); String strlon = Double.toString(loc.getLongitude()); String imageUrl = s; --------> 要讓menu 來修改 s變書 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.111.80.31

04/02 02:01, , 1F
這兩個是不同class裡的嗎?
04/02 02:01, 1F

04/02 02:04, , 2F
使用別的class裡的method記得要用class.method才行喔
04/02 02:04, 2F
※ 編輯: PHILLLU 來自: 140.111.80.31 (04/02 02:10)

04/02 02:12, , 3F
請問那該如何修改呢?如果我要用選單改變下面class的s 值
04/02 02:12, 3F

04/02 02:14, , 4F
是不同的類別 那要該如何修改程式呢?請大大指教 謝謝
04/02 02:14, 4F
文章代碼(AID): #19qwAl8n (java)
文章代碼(AID): #19qwAl8n (java)