forked from extern/Unexpected-Keyboard
CustomExtraKeysPreference: Reusable edit text layout
This layout is generically used by CustomExtraKeysPreference and LayoutsPreference.
This commit is contained in:
parent
03f2b8df70
commit
8611dbcfa0
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||||
<EditText android:id="@+id/key_name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="10dp"/>
|
<EditText android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="10dp"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -48,18 +48,17 @@ public class CustomExtraKeysPreference extends ListGroupPreference<String>
|
|||||||
void select(final SelectionCallback<String> callback)
|
void select(final SelectionCallback<String> callback)
|
||||||
{
|
{
|
||||||
new AlertDialog.Builder(getContext())
|
new AlertDialog.Builder(getContext())
|
||||||
.setView(R.layout.custom_extra_key_add_dialog)
|
.setView(R.layout.dialog_edit_text)
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener(){
|
||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface dialog, int which)
|
||||||
{
|
{
|
||||||
EditText input = (EditText)((AlertDialog)dialog).findViewById(R.id.key_name);
|
EditText input = (EditText)((AlertDialog)dialog).findViewById(R.id.text);
|
||||||
final String k = input.getText().toString();
|
final String k = input.getText().toString();
|
||||||
if (!k.equals(""))
|
if (!k.equals(""))
|
||||||
callback.select(k);
|
callback.select(k);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,13 +72,14 @@ public class LayoutsPreference extends ListGroupPreference<String>
|
|||||||
@Override
|
@Override
|
||||||
Serializer<String> get_serializer() { return SERIALIZER; }
|
Serializer<String> get_serializer() { return SERIALIZER; }
|
||||||
|
|
||||||
|
@Override
|
||||||
void select(final SelectionCallback callback)
|
void select(final SelectionCallback callback)
|
||||||
{
|
{
|
||||||
ArrayAdapter layouts = new ArrayAdapter(getContext(), android.R.layout.simple_list_item_1, _layout_display_names);
|
ArrayAdapter layouts = new ArrayAdapter(getContext(), android.R.layout.simple_list_item_1, _layout_display_names);
|
||||||
new AlertDialog.Builder(getContext())
|
new AlertDialog.Builder(getContext())
|
||||||
.setView(R.layout.custom_extra_key_add_dialog)
|
.setView(R.layout.dialog_edit_text)
|
||||||
.setAdapter(layouts, new DialogInterface.OnClickListener(){
|
.setAdapter(layouts, new DialogInterface.OnClickListener(){
|
||||||
public void onClick(DialogInterface dialog, int which)
|
public void onClick(DialogInterface _dialog, int which)
|
||||||
{
|
{
|
||||||
callback.select(_layout_names.get(which));
|
callback.select(_layout_names.get(which));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user