Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This link gives a superficial explanation: <a href="http://developer.android.com/guide/topics/ui/custom-components.html">http://developer.android.com/guide/topics/ui/custom-components.html</a></p> <p>Considering you have a CustomKeyboard that inherits from KeyboardView/View:</p> <ol> <li>Create your custom properties in res/values/attrs.xml file (create the file if it does not exist):</li> </ol> <blockquote> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;declare-styleable name="custom_keyboard"&gt; &lt;attr name="alternative_key_label" format="string" /&gt; &lt;/declare-styleable&gt; &lt;/resources&gt; </code></pre> </blockquote> <ol> <li><p>Create a constructor in your custom component overriding default constructor that receives the attribute set because this one will be called when the layout is loaded.</p> <pre><code>public CustomKeyboard(Context context, AttributeSet set) { super(context, set); TypedArray a = context.obtainStyledAttributes(set,R.styleable.custom_keyboard); CharSequence s = a.getString(R.styleable.custom_keyboard_alternative_key_label); if (s != null) { this.setAlternativeKeyLabel(s.toString()); } a.recycle(); } </code></pre></li> <li><p>In your layout file, add your custom component and the link to your resources.</p></li> </ol> <blockquote> <pre><code> &lt;Layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res/your.package.ProjectName" .../&gt; ... &lt;your.package.projectname.CustomKeyboard android:id="@+id/my_keyboard" ... app:alternative_key_label="F"&gt; &lt;/your.package.projectname.CustomKeyboard&gt; &lt;/Layout&gt; </code></pre> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload