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));
答案 0 :(得分:1)
String key = ((EditText)findViewById(R.id.etPutKey)).getText().toString());
((TextView)findViewById(R.id.tvShowValue)).setText(String.valueOf(ht.get(key)));