易生活(二)-APP—安卓中评论功能的实现
安卓评论效果,空间说说评论,社交2016-05-26
AndroidStudio
配置
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.facebook.fresco:fresco:0.9.0+'
}
如何实现点击“评论”之后跳出拼音输入法,代码如下:
/**
* 显示或隐藏输入法
*/
private void onFocusChange(boolean hasFocus) {
final boolean isFocus = hasFocus;
(new Handler()).postDelayed(new Runnable() {
public void run() {
InputMethodManager imm = (InputMethodManager)
MainActivity.this.getSystemService(INPUT_METHOD_SERVICE);
if (isFocus) {
//显示输入法
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
mAmEtMsg.setFocusable(true);
mAmEtMsg.requestFocus();
} else {
//隐藏输入法
imm.hideSoftInputFromWindow(mAmEtMsg.getWindowToken(), 0);
}
}
}, 100);
}
细节不再累述,参看源码