2014-04-22 4 views
0

안녕하세요 모두들 찾아 주셔서 감사합니다. 답변을 찾으십시오 ... 최고 점수 화면을 업데이트하려고합니다. 이다른 활동의 변수를 업데이트하십시오.

내가 그것을 새로운 점수 후 낮은 경우 hScoreGen1의 값을 변경하려면
HashMap<String,String> temp = new HashMap<String,String>(); 
     temp.put("catGeneral","Level 1"); 
     temp.put("score1", String.valueOf(hScoreGen1) + "/10"); 
     listGeneral.add(temp); 

... 지금까지 내가 다른이가이 내 목록을 채우고

SimpleAdapter adapter1 = new SimpleAdapter(
       this, 
       listGeneral, 
       R.layout.list_highscore_row, 
       new String[] {"catGeneral","score1"}, 
       new int[] {R.id.text1,R.id.text2} 
     ); 

내 어댑터입니다 hScoreGen1의 가치를 바꿔야하는 활동

if (totalCorrect > ScoreScreen.currentScoreCatValue){ //currentScoreCatValue is the orginal value of hScoreGen1 
          if (currentScoreCat == 1){ //currentScoreCat is set to 1 from another activity 
           HighScores.hScoreGen1 = totalCorrect; 

내 문제는 목록보기에 변경된 값이 표시되지 않는 것 같습니다. 에서 onCreate 값을 보여주는 ... 당신이 을 도울 수

+0

필요하다면 내가 더 많은 코드를 추가 할 수 있기를 바랍니다? notifyDataSetChanged(). 자세한 정보는 [Here] (http://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetChanged())에서도 Main UI 스레드에서 호출해야합니다. – Skynet

+0

'notifyDataSetChanged()'를 호출하십시오. –

+0

notifydatachanged()를 사용하여 HashMap 및 SimpleAdapter를 업데이트하십시오. –

답변

0

갱신 어댑터 당신은 목록보기를 새로 고쳐야 할

if (totalCorrect > ScoreScreen.currentScoreCatValue){ //currentScoreCatValue is the   orginal value of hScoreGen1 
         if (currentScoreCat == 1){ //currentScoreCat is set to 1 from another activity 
          HighScores.hScoreGen1 = totalCorrect; 
          HighScores.adapter1.notifydatachanged(); 
+0

미안합니다 karthick notifydatachanged();() notifydatachanged있어서 유형 SimpleAdapter 오류에 대한 정의되지하도록하고 나던 함) (notifydatasetchanged 저작물 – user3387276

+0

제가 쉽게 간단한 어댑터를 – user3387276

+0

공개 무효 setNewHighScore() { \t \t \t 경우 변경할 수 (totalCorrect> ScoreScreen 변경하라는 .currentScoreCatValue) {nullpointerexemption이 발생했습니다. \t \t \t \t \t HighScores.hScoreGen1 = totalCorrect; \t \t \t HighScores.adapter1.notifyDataSetChanged(); \t \t \t} \t} – user3387276