Back to project page android-textview-custom-fonts.
The source code is released under:
Copyright (c) 2014, Leo Kuznetsov All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ...
If you think the Android project android-textview-custom-fonts listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package sample.app; //from w w w .ja va 2 s .c om import android.os.*; import android.text.*; import android.view.*; import android.view.inputmethod.*; import android.widget.*; import custom.fonts.*; public class EditNameDialog extends CustomFontDialogFragment implements TextView.OnEditorActionListener { public interface Ender { void onFinishEditDialog(String inputText); } private EditText editor; public EditNameDialog() { // Empty constructor required for DialogFragment } public View onCreateView(LayoutInflater li, ViewGroup container, Bundle savedInstanceState) { View view = li.inflate(R.layout.fragment_edit_name, container); if (view != null && getDialog() != null) { editor = (EditText) view.findViewById(R.id.txt_your_name); getDialog().setTitle("Hello"); editor.requestFocus(); // Show soft keyboard automatically getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); editor.setOnEditorActionListener(this); } return view; } public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (EditorInfo.IME_ACTION_DONE == actionId && getActivity() instanceof Ender && editor != null) { // Return input text to activity Ender activity = (Ender) getActivity(); Editable text = editor.getText(); activity.onFinishEditDialog("" + text); this.dismiss(); return true; } return false; } }