当按钮点击时,我得到错误来实现隐藏键盘,任何人都知道如何解决这个问题? 在getSystemService和getWindowsToken实际误码当按钮点击时隐藏键盘(片段)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_calculator, container, false);
Button hitung = (Button) rootView.findViewById(R.id.hitung);
final EditText height = (EditText)rootView.findViewById(R.id.height);
final EditText weight = (EditText)rootView.findViewById(R.id.weight);
InputMethodManager imm = InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(EditText.getWindowToken(), 0);
final TextView result = (TextView)rootView.findViewById(R.id.result);
final TextView finalresult = (TextView)rootView.findViewById(R.id.finalresult);
finalresult.setMovementMethod(new ScrollingMovementMethod());
hitung.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
..........
}
我们能不能得到任何栈打印,在logcat的错误代码? – Amesys
嗨,即时通讯还没有运行,仍然出现bc错误,上getSystemService警告说:'不能解决方法getSystemService(Java.Lang.String)' –
是缺少'('在这一行中的一个错误?InputMethodManager imm = InputMethodManager)getSystemService (Context.INPUT_METHOD_SERVICE); –