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 |
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);
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.
dismiss();
| 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;
setTitle(R.string.select_character);
setContentView(R.layout.character_picker);
GridView grid = (GridView) findViewById(R.id.characterPicker);
grid.setAdapter(new OptionsAdapter(getContext()));
grid.setOnItemClickListener(this);
findViewById(R.id.cancel).setOnClickListener(this);
| public void | onItemClick(android.widget.AdapterView parent, android.view.View view, int position, long id)Handles clicks on the character buttons.
int selEnd = Selection.getSelectionEnd(mText);
String result = String.valueOf(mOptions.charAt(position));
if (mInsert || selEnd == 0) {
mText.insert(selEnd, result);
} else {
mText.replace(selEnd - 1, selEnd, result);
}
dismiss();
|
|