在接受以下帖子(Android自定义数字键盘)的答案中,我发现了一个我不理解的语法:
$(R.id.t9_key_0).setOnClickListener(this);
Run Code Online (Sandbox Code Playgroud)
美元符号在前面意味着什么?它是否与Android资源ID特别相关,还是更普通的Java语法?搜索引擎结果未显示任何合适的结果.
我正在研究自定义键盘应用程序


这是input.xml软键盘背景颜色的代码: -
@Override
public View onCreateInputView() {
Log.e("onStartInputView ","On StartInput View Called--");
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
String Backgroundcolour = preferences.getString("BackgroundColour","");
Log.e("Brithnesss- -","----"+Backgroundcolour);
if(Backgroundcolour.equalsIgnoreCase("black"))
{
this.mInputView = (KeyboardView) getLayoutInflater().inflate(
R.layout.input, null);
}else
{
this.mInputView = (KeyboardView) getLayoutInflater().inflate(
R.layout.input1, null);
//this.mInputView.setB
}
this.mInputView.setOnKeyboardActionListener(this);
this.mInputView.setKeyboard(this.mQwertyKeyboard);
return this.mInputView;
}
@Override public void onStartInputView(EditorInfo attribute, boolean restarting) {
super.onStartInputView(attribute, restarting);
// Apply the selected keyboard to the input view.
setInputView(onCreateInputView());
}
Run Code Online (Sandbox Code Playgroud)
我没有得到如何设置特定键的背景图像.
我从这里复制了整个代码
并在AlertDialog. 现在,当我调试应用程序时,onClick()不会调用该应用程序。
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setView(R.layout.keypad_layout);
builder.setCancelable(false).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.setPositiveButton("Modify", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
builder.create().show();\
Run Code Online (Sandbox Code Playgroud)
警报对话框正在显示,正负按钮可以工作,唯一的问题是我无法访问布局内的视图