哈希表来getkey [英] Hash table to getkey

查看:96
本文介绍了哈希表来getkey的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,大家好我想提出哈希表的关键,在随后的EditText显示我的价值在TextView中

 的Hashtable<字符串,整数> HT =新的Hashtable<字符串,整数>();
//枚举<字符串> ENM;
ht.put(rakan,100);
ht.put(艾哈迈德,200);
ht.put(卫生部,3000);


迭代器<字符串> myVeryOwnIterator = ht.keySet()迭代器()。
而(myVeryOwnIterator.hasNext()){
    字符串键=(字符串)myVeryOwnIterator.next();
    整数值=(整数)ht.get(密钥);
    Toast.makeText(getBaseContext(),关键:+键+值:+值,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))。
 

解决方案

 字符串键=((的EditText)findViewById(R.id.etPutKey))。gettext的()。的toString() );
((TextView中)findViewById(R.id.tvShowValue))的setText(将String.valueOf(ht.get(键)));
 

hey guys i want to put key of hashtable in the edittext then show me the value in the textview

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

解决方案

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

这篇关于哈希表来getkey的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆