我想在活动中使用alertdialog显示我自己的自定义键盘(不是android的默认软键盘)。我有自定义键盘代码,但我不知道如何使用alertDialog实现它。请帮忙。这是我的项目。
感谢
这是我的代码:
private void showSaveDraftDialog() {
if (!list.isEmpty()) {
LayoutInflater li = LayoutInflater.from(Activity_Sales_Return.this);
View promptsView = li.inflate(R.layout.save_draft, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
Activity_Sales_Return.this);
// set prompts.xml to alertdialog builder
alertDialogBuilder.setView(promptsView);
final EditText userInput = (EditText) promptsView
.findViewById(R.id.et_alert_save_name);
// set dialog message
alertDialogBuilder.setCancelable(false).setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
//-------my code
})
.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog1 = alertDialogBuilder.create();
alertDialog1.setTitle("Save Draft");
alertDialog1.setIcon(R.drawable.ttt_logo);
userInput.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
showCustomKeyboard(v);
}
});
userInput.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// To hide default keyboard
InputMethodManager hide = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
hide.hideSoftInputFromWindow(userInput.getWindowToken(),0);
showCustomKeyboard(v);
}
});
alertDialog1.show();
} else {
Toast.makeText(mActivity, "No Sale started yet !!",
Toast.LENGTH_SHORT).show();
}
}