2013-07-08 46 views
0

嘿傢伙我希望把哈希表的關鍵在隨後的EditText給我看在TextView的價值哈希表信息getKey

Hashtable<String, Integer> ht=new Hashtable<String, Integer>(); 
//Enumeration<String> enm; 
ht.put("rakan", 100); 
ht.put("ahmad", 200); 
ht.put("moh", 3000); 


Iterator<String> myVeryOwnIterator = ht.keySet().iterator(); 
while(myVeryOwnIterator.hasNext()) { 
    String key=(String)myVeryOwnIterator.next(); 
    Integer value=(Integer)ht.get(key); 
    Toast.makeText(getBaseContext(), "Key: "+key+" Value: "+value , Toast.LENGTH_LONG).show(); 
} 


//(TextView)findViewById(R.id.tvShowValue).setTex(Integer.valueOf(+key)); 

//enm=ht.keys(); 
int id= Integer.parseInt(((EditText)findViewById(R.id.etPutKey)).getText().toString()); 
((TextView)findViewById(R.id.tvShowValue)).setText(Integer.valueOf(id)); 

回答

1
String key = ((EditText)findViewById(R.id.etPutKey)).getText().toString()); 
((TextView)findViewById(R.id.tvShowValue)).setText(String.valueOf(ht.get(key))); 
+0

錯誤代碼:(當我運行它 –

+0

整數轉換成字符串編輯答案 – oks16