flex自定義自帶下拉查詢功能的textinput

2021-06-28 19:18:55 字數 2783 閱讀 1044

自己寫了乙個不是太完美的自帶下拉查詢功能結果的textinput

先看看,執行截圖:

一共三個類:自定義的textinput類,自定義event類,外部呼叫類

自定義的textinput類:

package components

return item.tolowercase().search(str) != -1;

} private function textchangehandler():void

}private function showorhide():void

list.selectedindex = 0;

}else

}}

override protected function createchildren():void

list.showscrolltips = true;

list.showdatatips = true;

list.dataprovider = dataprovider;

list.setstyle("dropshadowenabled", true);

list.addeventlistener(listevent.item_click, selectitem);

showorhide();

systemmanager.addeventlistener(event.resize, removepopup, false, 0, true);

} override protected function updatedisplaylist(unscaledwidth:number, unscaledheight:number):void

override protected function measure():void

private function textinput_keydownhandler(event:keyboardevent):void

else

textinput.setselection(0, textinput.text.length);

break;

case keyboard.up:

if (islistvisible && list.selectedindex > 0)

textinput.setselection(0, textinput.text.length);

textinput.text.length); // select nothing

break;

case keyboard.enter:

if (islistvisible) selectitem();

break;

case keyboard.escape:

if (islistvisible) removepopup();

break;

}}

private function textinput_changehandler(event:event):void

private function list_mousedownoutsidehandler(event:mouseevent):void

private function selectitem(event:listevent = null):void

else

text = textinput.text;

dispatchevent(new searchboxevent(searchboxevent.item_selected, list.selecteditem));

removepopup();

} public function get selecteditem():object

return list.selecteditem;

} private function popup():void

private function removepopup(event:event=null):void

private function closehandler(event:mouseevent):void

public function get dataprovider():object

public function set dataprovider(dp:object):void

public function get text():string

public function set text(value:string):void

public function get labelfield():string

public function set labelfield(value:string):void}}

自定義event類:

package components

}}

外部呼叫類:

<?xml version="1.0" encoding="utf-8"?>

xmlns:s="library:"

xmlns:mx="library:" xmlns:components="components.*">@namespace s "library:";

@namespace mx "library:";

@namespace local "*";

s|label

如何自定義listview自帶下劃線的長度和顏色

有時候我們的listview當中需要實現listview下劃線顏色和長度的改動,怎麼做呢?xml直接改 1.在drawable下建立乙個自定義的布局,我的是 list divider.xml xml version 1.0 encoding utf 8 xmlns android android r...

自定義下拉列表

請選擇span class arrow down i class box prompt up notshow 1li 2li 3li 4li class tri i div div spinner btn spinner btn default txt spinner btn arrow down ...

Flex自定義元件

使用mxml標籤定義 主檔案main1.mxml 注 xmlns mycomp 自定義命名空間其實很類似於包的概念用來管理元件的。實際當中最好把自己的元件檔案分資料夾管理。元件定義mycomp1.mxml 濟南威海 煙台注 元件的檔名就對應著將來使用時的mxml標籤名,根標籤就是你用來擴充套件的父類...