0

嘿伙计们,我想把哈希表的键放在编辑文本中,然后在文本视图中显示值

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));
4

1 回答 1

1
String key = ((EditText)findViewById(R.id.etPutKey)).getText().toString());
((TextView)findViewById(R.id.tvShowValue)).setText(String.valueOf(ht.get(key)));
于 2013-07-08T12:12:53.133 回答