看板 java 關於我們 聯絡資訊
各位大大好 小弟我 目前在寫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
joylo:這兩個是不同class裡的嗎? 04/02 02:01
joylo:使用別的class裡的method記得要用class.method才行喔 04/02 02:04
※ 編輯: PHILLLU 來自: 140.111.80.31 (04/02 02:10)
PHILLLU:請問那該如何修改呢?如果我要用選單改變下面class的s 值 04/02 02:12
PHILLLU:是不同的類別 那要該如何修改程式呢?請大大指教 謝謝 04/02 02:14