我正在尝试创建一个 android 键盘,这段代码到目前为止工作正常
package keyboard.rob.com;
import...
public class xyz extends InputMethodService
implements KeyboardView.OnKeyboardActionListener {
private LinearLayout mInputView;
@Override public View onCreateInputView() {
mInputView = (LinearLayout) getLayoutInflater().inflate(R.layout.main, null);
return mInputView;
}
...
但稍后当我尝试制作
LinearLayout LinLayBg = (LinearLayout)findViewById(R.id.LL_total);
用按钮填充它,它显示
“*方法 findViewById(int) 未定义类型 zyz *”
有什么想法吗?谢谢!
最佳答案
我认为您正在尝试从 View 的非实例调用方法 findViewById(int id);
。
尝试:
mInputView.findViewById(R.id.LL_total);
希望对你有帮助
关于java - findViewById 在 InputMethodService 中不起作用,我该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7244172/