2013-07-08 51 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