您的位置:首页 > 其它

开发中遇到的小问题及解决方法

2014-09-12 18:24 162 查看
这篇博客用来记录日常开发和工作中遇到的小问题以及解决办法。。。

(问题一)隐藏软键盘问题----软键盘弹出后,页面刷新软键盘没有隐藏

解决代码:

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
mEditText为当前获取到焦点的输入框

(问题二)Bitmap和Drawable之间的相互转换

⒈Bitmap转换成Drawable

Bitmap bm = xxxxx;

Drawable mDrawable = new BitmapDrawable(bm);

⒉Drawable转换成Bitmap

Drawable d=xxxxx;

BitmapDrawable bd = (BitmapDrawable) d;

Bitmap bm = bd.getBitmap();

或者

Bitmap bitmap = BitmapFactory.decodeResource(getResources(),

R.drawable.d);

⒊EditText保留2位小数

首先在values文件夹的strings.xml文件中定义以下规则

<string name="amount_format">%.2f</string>

然后在EditText设置值:

mEdit.setText(String.format(getString(R.string.amount_format), 21.99999));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: