I've made it possible to change the "extra" properties from the layout xml, but I came across two major flaws:
1. even after adding the xmlns declaration to the layout.xml page, I do not have any intellisens/autocompletion of the new properties (I would expect to have the same "autocomplete" feature that the original EditText attributes has)
2. I found a post that describes the second issue perfectly: http://www.anddev.org/custom_xml_attrib ... t2830.html
I still have not committed those changes to the google code project due to these flaws... If there is a way to fix it, I will commit them.
these are the changes:
attr.xml:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <declare-styleable name="ThresholdEditText">
- <attr name="Threshold" format="integer"/>
- <attr name="DisableThresholdOnEmptyInput" format="boolean"/>
- </declare-styleable>
- </resources>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
ThreshildEditText.java (some more changes were made, that aren't here):
Using java Syntax Highlighting
- /**
- * Load properties values from xml layout
- */
- private void initAttributes(AttributeSet attrs) {
- if (attrs != null) {
- // Get the styles attributes
- TypedArray res = getContext().obtainStyledAttributes(attrs,R.styleable.ThresholdEditText);
- // Load values to local members
- this.threshold = res.getInteger(R.styleable.ThresholdEditText_Threshold, 500);
- this.disableThresholdOnEmptyInput = res.getBoolean(R.styleable.ThresholdEditText_DisableThresholdOnEmptyInput, true);
- }
- else {
- // Default threshold value is 0.5 seconds
- threshold = 500;
- // Default behaviour on emptied text - no threshold
- disableThresholdOnEmptyInput = true;
- }
- }
Parsed in 0.012 seconds, using GeSHi 1.0.8.4
and the layout.xml:
Using xml Syntax Highlighting
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:ma="http://schemas.android.com/apk/res/com.MobileAnarchy.ThresholdEditText"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
- <LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_margin="10dip">
- <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingRight="10px" android:text="@string/UserInput"></TextView>
- <com.MobileAnarchy.ThresholdEditText.ThresholdEditText
- android:layout_height="wrap_content"
- android:layout_width="fill_parent"
- android:id="@+id/EditTextInput"
- android:lines="1"
- ma:Threshold="500"
- ma:DisableThresholdOnEmptyInput="true" />
- </LinearLayout>
- <!-- The rest of of the content was ommited -->
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
Thanks again,
Oded O.