Java 构造函数自定义键盘(LoginDialog,int,int)未定义
我正在尝试在我的应用程序中实现自定义键盘,我需要在登录对话框提示时使用它 我试图实现以下示例: 但是,当我试图在线实现代码时,代码中出现了一个错误:Java 构造函数自定义键盘(LoginDialog,int,int)未定义,java,android,constructor,android-softkeyboard,android-keypad,Java,Android,Constructor,Android Softkeyboard,Android Keypad,我正在尝试在我的应用程序中实现自定义键盘,我需要在登录对话框提示时使用它 我试图实现以下示例: 但是,当我试图在线实现代码时,代码中出现了一个错误: mCustomKeyboard= new CustomKeyboard(this, R.id.keyboardview, R.xml.hexkbd ); 声明“构造函数CustomKeyboard(LoginDialog,int,int)是未定义的LoginDialog.java” 我已尝试将构造函数更改为: public CustomK
mCustomKeyboard= new CustomKeyboard(this, R.id.keyboardview, R.xml.hexkbd );
声明“构造函数CustomKeyboard(LoginDialog,int,int)是未定义的LoginDialog.java”
我已尝试将构造函数更改为:
public CustomKeyboard(Activity host, int viewid, int layoutid) {
mHostActivity= host;
到
但是它会导致代码中其他问题的多米诺效应,所以我认为有更好的方法来实现这个构造函数
LoginDialog.java
CustomKeyboard.java
附言
非常感谢您的任何建议。。。如有要求,可/将立即提供额外信息/来源
完整来源可在此处找到:
这里的问题是,通过在构造函数中提供
this
,您指向的是继承自DialogFragment
的LoginDialog
,它是Fragment
的子类,而构造函数期望Activity
或其任何子类。我不知道完整的代码,但是如果您需要向构造函数提供Activity
,您可以使用HostingActivity.this
。如果要使用此构造函数,请执行以下操作:
public CustomKeyboard(LoginDialog loginDialog, int viewid, int layoutid)
您可以通过调用loginDialog.getActivity()
来获取托管活动,并且可以通过loginDialog.getView()
在“活动”视图中搜索编辑文本
您应该将对话框视图添加到CustomKeyboard构造函数中,然后让RegisterEdit Text在那里搜索编辑文本eclipse错误消失了,但我遇到了一个强制关闭问题-有什么想法/建议吗@USER358561我相信这是另一个潜水问题,但是无论如何,<代码> CudioBoo.ReistSerEdTeX(CuutoBoo.java:150)需要说什么“你说的是CuoCueBoosik.RealStestEdtEngt需要说什么”@ USE358561我是说这个函数需要找到崩溃的根本原因。但无论如何,这是另一个问题
public class LoginDialog extends DialogFragment implements
ActionCompletedListener {
private View view;
private String whichActivity = "";
private TextView error;
CustomKeyboard mCustomKeyboard;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(
new ContextThemeWrapper(getActivity(), R.style.HoloDarkDialog));
LayoutInflater inflater = getActivity().getLayoutInflater();
view = inflater.inflate(R.layout.login, null);
mCustomKeyboard = new CustomKeyboard(this, R.id.keyboardview,
R.xml.hexkbd);
public CustomKeyboard(Activity host, int viewid, int layoutid) {
mHostActivity= host;
mKeyboardView= (KeyboardView)mHostActivity.findViewById(viewid);
mKeyboardView.setKeyboard(new Keyboard(mHostActivity, layoutid));
mKeyboardView.setPreviewEnabled(false); // NOTE Do not show the preview balloons
mKeyboardView.setOnKeyboardActionListener(mOnKeyboardActionListener);
// Hide the standard keyboard initially
mHostActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
public CustomKeyboard(LoginDialog loginDialog, int viewid, int layoutid)
registerEditText(int resid)