CharacterPickerDialogpublic class CharacterPickerDialog extends android.app.Dialog implements android.widget.AdapterView.OnItemClickListener, android.view.View.OnClickListenerDialog for choosing accented characters related to a base character. |
Fields Summary |
---|
private android.view.View | mView | private Editable | mText | private String | mOptions | private boolean | mInsert | private android.view.LayoutInflater | mInflater | private android.widget.Button | mCancelButton |
Constructors Summary |
---|
public CharacterPickerDialog(android.content.Context context, android.view.View view, Editable text, String options, boolean insert)Creates a new CharacterPickerDialog that presents the specified
options for insertion or replacement (depending on
the sense of insert ) into text .
super(context, com.android.internal.R.style.Theme_Panel);
mView = view;
mText = text;
mOptions = options;
mInsert = insert;
mInflater = LayoutInflater.from(context);
|
Methods Summary |
---|
public void | onClick(android.view.View v)Handles clicks on the Cancel button.
if (v == mCancelButton) {
dismiss();
} else if (v instanceof Button) {
CharSequence result = ((Button) v).getText();
replaceCharacterAndClose(result);
}
| protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
WindowManager.LayoutParams params = getWindow().getAttributes();
params.token = mView.getApplicationWindowToken();
params.type = params.TYPE_APPLICATION_ATTACHED_DIALOG;
params.flags = params.flags | Window.FEATURE_NO_TITLE;
setContentView(R.layout.character_picker);
GridView grid = (GridView) findViewById(R.id.characterPicker);
grid.setAdapter(new OptionsAdapter(getContext()));
grid.setOnItemClickListener(this);
mCancelButton = (Button) findViewById(R.id.cancel);
mCancelButton.setOnClickListener(this);
| public void | onItemClick(android.widget.AdapterView parent, android.view.View view, int position, long id)Handles clicks on the character buttons.
String result = String.valueOf(mOptions.charAt(position));
replaceCharacterAndClose(result);
| private void | replaceCharacterAndClose(java.lang.CharSequence replace)
int selEnd = Selection.getSelectionEnd(mText);
if (mInsert || selEnd == 0) {
mText.insert(selEnd, replace);
} else {
mText.replace(selEnd - 1, selEnd, replace);
}
dismiss();
|
|