亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
characters

CursorTreeAdapter

翻譯時間:2011-1-24

版本:Android 3.0 r1

結(jié)構(gòu)

繼承關(guān)系

public abstract class CusrorTreeAdapter

???????? extends BaseExpandableListAdpater implements Filterable

?

java.lang.Object

android.widget.BaseExpandableListAdapter

???????? android.widget.CursorTreeAdapter

?

子類及間接子類

直接子類

???????? ResourceCursorTreeAdapter

間接子類

SimpleCursorTreeAdapter

?

類概述

通過該適配類可以用一連續(xù)的游標(biāo)(Coursor)對象訪問數(shù)據(jù)庫,并將查詢出來的數(shù)據(jù)展示到可伸縮的列表視圖(ExpandableListView)部件上。頂層游標(biāo)(Cursor)對象(在構(gòu)造器中指定)顯示全部組,后面的游標(biāo)(Cursor)對象從getChildrenCursor(Cursor)獲取并展示子元素組。其中游標(biāo)攜帶的結(jié)果集中必須有個名為“_id”的列,否則這個類不起任何作用。

?

構(gòu)造函數(shù)

public CursorTreeAdapter (Cursor cursor, Context context)

???????? 構(gòu)造函數(shù)。每當(dāng)數(shù)據(jù)庫的數(shù)據(jù)發(fā)生改變時,適配器將調(diào)用requery()重新查詢以顯示最新的數(shù)據(jù)。

?????????????????? 參數(shù)

cursor?????? 為組(groups)提供數(shù)據(jù)的游標(biāo)(Coursor)

?????????????????? context??? 應(yīng)用程序上下文。

?

public CursorTreeAdapter (Cursor cursor, Context context, boolean autoRequery)

???????? 構(gòu)造函數(shù)。

?????????????????? 參數(shù)

cursor?????? 為組(groups)提供數(shù)據(jù)的游標(biāo)(Coursor)

?????????????????? context??? 應(yīng)用程序上下文。

??????????????????????????? autoRequery? 設(shè)置為true時,每當(dāng)數(shù)據(jù)庫的數(shù)據(jù)發(fā)生改變時,適配器將調(diào)用requery()重新查詢以顯示最新的數(shù)據(jù)。

?

公共方法

public void changeCursor (Cursor cursor)

更改相關(guān)的游標(biāo)為新傳入的游標(biāo)。如果游標(biāo)已經(jīng)存在則先關(guān)閉這個已存在的游標(biāo)。

參數(shù)

??????????????????????????? cursor ????????????? 新游標(biāo)(Cursor)對象。

?

public CharSequence convertToString (Cursor cursor)

cursor轉(zhuǎn)換成CharSequence。子類應(yīng)該重寫這個方法并轉(zhuǎn)換它們的結(jié)果。這個方法的默認(rèn)實現(xiàn)是:當(dāng)cursor為空時返回一個空串,否則直接返回調(diào)用cursortoString()方法。

參數(shù)

??????????????????????????? cursor ????????????? cursor轉(zhuǎn)換成CharSequence對象。?????????????????

???????? 返回值

?????????????????? 返回CharSequence類型的值(譯者注:這個值是通過轉(zhuǎn)換參數(shù)cursor類型而獲得的。)

?

public Cursor getChild (int groupPosition, int childPosition)

???????? 獲取指定組中的指定子元素的相關(guān)數(shù)據(jù)。

???????? ???????? 參數(shù)

??????????????????????????? groupPosition? 組位置(該組內(nèi)部含有子元素)

?????????????????? ???????? childPosition??? 子元素位置(相對于其它子元素)

???????? ???????? 返回值

??????????????????????????? 返回指定子元素數(shù)據(jù)。

?

public long getChildId (int groupPosition, int childPosition)

獲取指定組中的指定子元素ID,這個ID在組里一定是唯一的。聯(lián)合ID(參見getCombinedChildId(long, long))在所有條目(所有組和所有元素)中也是唯一的。

?????????????????? 參數(shù)

??????????????????????????? groupPosition? 組位置(該組內(nèi)部含有子元素)

?????????????????? ???????? childPosition??? 子元素位置(相對于其它子元素)

?????????????????? 返回值

???????? ???????? 子元素關(guān)聯(lián)ID。

?

???????? public View getChildView (int groupPosition, int childPosition, boolean isLastChild, ? View convertView, ViewGroup parent)

獲取一個視圖對象,顯示指定組中的指定子元素數(shù)據(jù)。

???????? ???????? 參數(shù)

?????????????????? ???????? groupPosition? 組位置(該組內(nèi)部含有子元素)

?????????????????? ???????? childPosition?? 子元素位置(決定返回哪個視圖)

?????????????????? ???????? isLastChild??? 子元素是否處于組中的最后一個

convertView? 重用已有的視圖(View)對象。注意:在使用前你應(yīng)該檢查一下這個視圖對象是否非空并且這個對象的類型是否合適。由此引伸出,如果該對象不能被轉(zhuǎn)換并顯示正確的數(shù)據(jù),這個方法就會調(diào)用getChildView(int, int, boolean, View, ViewGroup)來創(chuàng)建一個視圖(View)對象。

?????????????????? ???????? parent? ?????????? 返回的視圖(View)對象始終依附于的視圖組。

???????? ???????? 返回值

?????????????????? ???????? 指定位置上的子元素返回的視圖對象

?

public int getChildrenCount (int groupPosition)

???????? 獲取指定組中的子元素個數(shù)

?????????????????? 參數(shù)

??????????????????????????? groupPosition? 組位置(決定返回哪個組的子元素個數(shù))

?????????????????? 返回值

??????????????????????????? 返回組中的子元素個數(shù)

?

public Cursor getCursor ()

???????? 返回當(dāng)前適配器綁定的Cursor對象。

返回值

??????????????????????????? Cursor對象。

?

public Filter getFilter ()

???????? 返回一個可以通過一種過濾模式來約束數(shù)據(jù)的過濾器。

???????? 這個方法通常在Adapter類中實現(xiàn)。

返回值

??????????????????????????? 返回一個用來限制數(shù)據(jù)的過濾器(Filter)對象。

?

public FilterQueryProvider getFilterQueryProvider ()

返回一個提供過濾的查詢過濾器。若過濾器為null,則不再過濾。

返回值

??????????????????????????? 返回當(dāng)前過濾器對象,如果不存在返回null

?????????????????? 參考

?????????????????? getFilterQueryProvider()

?

public Cursor getGroup (int groupPosition)

獲取指定組中的數(shù)據(jù)

?????????????????? 參數(shù)

??????????????????????????? groupPosition? 組位置

?????????????????? 返回值

???????? ?????????????????? 返回組中的數(shù)據(jù),也就是該組中的子元素數(shù)據(jù)。

?

public int getGroupCount ()

???????? 獲取組的個數(shù)

?????????????????? 返回值

???????? ???????? ???????? 組的個數(shù)

?

public long getGroupId (int groupPosition)

???????? 獲取指定組的ID,這個組ID必須是唯一的。聯(lián)合ID(參見getCombinedGroupId(long))在所有條目(所有組和所有元素)中也是唯一的。

?????????????????? 參數(shù)

??????????????????????????? groupPosition? 組位置

?????????????????? 返回值

??????????????????????????? 返回組ID

?

public View getGroupView (int groupPosition, boolean isExpanded, View ????????? convertView, ViewGroup parent)

???????? 獲取顯示指定組的視圖對象。這個方法僅返回關(guān)于組的視圖對象,要想獲取子元素的視圖對象,就需要調(diào)用getChildView(int, int, boolean, View, ViewGroup)。

???????? 參數(shù)

?????????????????? groupPosition? 組位置(決定返回哪個視圖)

?????????????????? isExpanded? ? ?該組是展開狀態(tài)還是伸縮狀態(tài)

convertView? ?重用已有的視圖對象。注意:在使用前你應(yīng)該檢查一下這個視圖對象是否非空并且這個對象的類型是否合適。由此引伸出,如果該對象不能被轉(zhuǎn)換并顯示正確的數(shù)據(jù),這個方法就會調(diào)用getGroupView(int, boolean, View, ViewGroup)來創(chuàng)建一個視圖(View)對象。

?????????????????? parent? ?????????? 返回的視圖對象始終依附于的視圖組。

???????? 返回值

?????????????????? 返回指定組的視圖對象

?

???????? public boolean hasStableIds ()

???????? 組和子元素是否持有穩(wěn)定的ID,也就是底層數(shù)據(jù)的改變不會影響到它們。

???????? 返回值

??????????????????????????? 返回一個Boolean類型的值,如果為TRUE,意味著相同的ID永遠(yuǎn)引用相同的對象。

?

???????? public boolean isChildSelectable (int groupPosition, int childPosition)

???????? 是否選中指定位置上的子元素。

?????????????????? 參數(shù)

??????????????????????????? groupPosition? 組位置(該組內(nèi)部含有子元素)

??????????????????????????? childPosition? ?子元素位置

?????????????????? 返回值

???????? ???????? 是否選中子元素

?

???????? public void notifyDataSetChanged (boolean releaseCursors)

???????? 通知數(shù)據(jù)集已改變,該方法還為任何帶有緩存功能的游標(biāo)提供不用釋放資源的可選功能。

?????????????????? 參數(shù)

???????? ???????? releaseCursors? 是否釋放任何帶有緩沖功能的游標(biāo)資源

?

???????? public void notifyDataSetChanged ()

???????? 該方法內(nèi)部實現(xiàn)了在每個觀察者上面調(diào)用onChanged事件。每當(dāng)發(fā)現(xiàn)數(shù)據(jù)集有改變的情況,或者讀取到數(shù)據(jù)的新狀態(tài)時,就會調(diào)用此方法。

?

???????? public void notifyDataSetInvalidated ()

???????? 該方法內(nèi)部實現(xiàn)了在每個觀察者上面調(diào)用onInvalidated事件。每當(dāng)發(fā)現(xiàn)數(shù)據(jù)集監(jiān)控有改變的情況,比如該數(shù)據(jù)集不再有效,就會調(diào)用此方法。

?

???????? public void onGroupCollapsed (int groupPosition)

???????? 當(dāng)指定組收縮狀態(tài)的時候調(diào)用此方法。

?????????????????? 參數(shù)

??????????????????????????? groupPosition? 指定組收縮狀態(tài)

?

public Cursor runQueryOnBackgroundThread (CharSequence constraint)

執(zhí)行含指定約束的查詢。此查詢依賴于適配器的過濾器。查詢是由FilterQueryProvider提供。如果沒有指定FilterQueryProvider,當(dāng)前cursor不過濾只返回。該方法會通過changeCursor(Cursor)方法返回一個Cursor對象,并且關(guān)閉掉先前的Cursor對象。這個方法始終在后臺線程執(zhí)行,而不是在應(yīng)用程序的主線程(或是UI線程)中運(yùn)行。規(guī)定:當(dāng)參數(shù)constraintnull或為空時,該方法返回原始結(jié)果。

???????? 參數(shù)

?????????????????? constraint? 當(dāng)某個查詢需要過濾功能,使用參數(shù)constraint作為約束條件。

返回值

??????????????????????????? 返回含有新的查詢結(jié)果的Cursor。

參考

???????? getFilter()

getFilterQueryProvider()

?????????????????? setFilterQueryProvider(android.widget.FilterQueryProvider)

?

???????? public void setChildrenCursor (int groupPosition, Cursor childrenCursor)

???????? 為指定組子元素設(shè)置游標(biāo)(Cursor),并關(guān)閉已存在的游標(biāo)。這個方法是非常有用的,當(dāng)進(jìn)行異步查詢操作的時候用來避免UI發(fā)生阻塞的情況。

???????? 參數(shù)

?????????????????? groupPosition? ?組位置(組中的哪個子元素要設(shè)置游標(biāo)對象)

???????? ?????????????????? childrenCursor? 組子元素的游標(biāo)(Cursor)

?

???????? public void setFilterQueryProvider (FilterQueryProvider filterQueryProvider)

設(shè)置一個過濾器,用來過濾當(dāng)前的Cursor對象。當(dāng)這個適配器需要進(jìn)行過濾操作時, runQuery(CharSequence)方法被調(diào)用。

???????? 參數(shù)

?????????????????? filterQueryProvider ?過濾生成器對象,設(shè)置為null時,就相當(dāng)于移除了該生?????? 成器 。

?????????????????? 參考

??????????????????????????? getFilterQueryProvider()

?????????????????? ???????? runQueryOnBackgroundThread(CharSequence)

?

???????? public void setGroupCursor (Cursor cursor)

???????? 設(shè)置組游標(biāo)對象。

?????????????????? 參數(shù)

???????? ???????? ???????? cursor? 設(shè)置組游標(biāo)對象,并關(guān)閉已存在的游標(biāo)對象。

?

受保護(hù)方法

???????? protected abstract void bindChildView (View view, Context context, Cursor cursor, ???????? boolean isLastChild)

???????? 用游標(biāo)(Coursor)的方式將子元素數(shù)據(jù)綁定在一個已存在的視圖(View)對象上。

?????????????????? 參數(shù)

??????????????????????????? view? ???? ??????? 已存在的視圖(View)對象, 也就是之前new出來的。

??????????????????????????? context? ???????? 應(yīng)用程序上下文對象

??????????????????????????? cursor? ?????????? 獲取數(shù)據(jù)的游標(biāo)對象,它已經(jīng)移動到正確的位置

??????????????????????????? IsLastChild? ??子元素是否處于組中的最后一個

?

???????? protected abstract void bindGroupView (View view, Context context, Cursor cursor, ????? boolean isExpanded)

???????? 用游標(biāo)(Coursor)的方式將組數(shù)據(jù)綁定在一個已存在的視圖(View)對象上。

?????????????????? 參數(shù)

??????????????????????????? view? ???? ??????? 已存在的組視圖(View)對象, 也就是早先new出來的。

??????????????????????????? context? ???????? 應(yīng)用程序上下文對象,它已經(jīng)移動到正確的位置

??????????????????????????? cursor? ?????????? 獲取數(shù)據(jù)的游標(biāo)對象

??????????????????????????? isExpanded?? 該組是展開狀態(tài)還是伸縮狀態(tài)

?

???????? protected abstract Cursor getChildrenCursor (Cursor groupCursor)

???????? 獲取指定組中的子元素游標(biāo)對象。子類必須實現(xiàn)這個方法,用于在指定組中返回子元素數(shù)據(jù)。

如果你想用異步查詢的方式避免UI阻塞的情況發(fā)生,可能會返回null或是在稍后調(diào)用setChildrenCursor(int, Cursor)。

你有責(zé)任在Activity生命周期中管理這個游標(biāo)對象,有一個非常好的思路:使用managedQuery(Uri, String[], String, String[], String)來管理它們。在某些情況下,適配器本身會使游標(biāo)停止工作,但這個特例不會總是出現(xiàn),所以我們要確保有效地管理好游標(biāo)對象。

?????????????????? 參數(shù)

??????????????????????????? groupCursor? 組游標(biāo)對象,決定返回哪個組中的子元素游標(biāo)對象。

?????????????????? 返回值

??????????????????????????? 返回指定組中的子元素游標(biāo)對象或者為null。

?

???????? protected abstract View newChildView (Context context, Cursor cursor, boolean ??? isLastChild, ViewGroup parent)

???????? 創(chuàng)建一個新的子元素視圖并持有指向數(shù)據(jù)的游標(biāo)cursor

?????????????????? 參數(shù)

??????????????????????????? context? ???????? 應(yīng)用程序上下文對象

??????????????????????????? cursor? ?????????? 獲取數(shù)據(jù)的游標(biāo)對象,它已經(jīng)移動到正確的位置

??????????????????????????? IsLastChild? ?子元素是否處于組中的最后一個

??????????????????????????? parent? ????新視圖(View)所依附于的父對象。

?

???????? protected abstract View newGroupView (Context context, Cursor cursor, boolean isExpanded, ViewGroup parent)

???????? 創(chuàng)建一個新的組視圖并持有組中指向數(shù)據(jù)的游標(biāo)cursor。

?????????????????? 參數(shù)

??????????????????????????? context? ???????? 應(yīng)用程序上下文對象

??????????????????????????? cursor? ?????????? 獲取數(shù)據(jù)的游標(biāo)對象,它已經(jīng)移動到正確的位置

??????????????????????????? isExpanded?? 該組是否展開狀態(tài)

??????????????????????????? parent? ?????新視圖(View)所依附于的父對象。

?

補(bǔ)充

???????? 文章精選

?????????????????? 說說定制自己的CursorAdapter

?


Previous article: Next article: