Search in sources :

Example 1 with StickyListHeadersListView

use of com.emilsjolander.components.stickylistheaders.StickyListHeadersListView in project little-bear-dictionary by daimajia.

the class WordsFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    StickyListHeadersListView stickyList = (StickyListHeadersListView) view.findViewById(R.id.list);
    stickyList.setDivider(new ColorDrawable(0xffffffff));
    stickyList.setDividerHeight(1);
    stickyList.setOnScrollListener(this);
    stickyList.setOnItemClickListener(this);
    stickyList.setOnHeaderClickListener(this);
    if (savedInstanceState != null) {
        firstVisible = savedInstanceState.getInt(KEY_LIST_POSITION);
    }
    DictionaryDB dictionaryDB = new DictionaryDB(getActivity(), DictionaryDB.DB_NAME, null, DictionaryDB.DB_VERSION);
    SQLiteDatabase sqLiteDatabase = dictionaryDB.getReadableDatabase();
    Cursor cursor = sqLiteDatabase.rawQuery("select * from word order by word", null);
    WordAdapter wordAdapter = new WordAdapter(getActivity(), cursor);
    stickyList.setAdapter(wordAdapter);
    stickyList.setSelection(firstVisible);
}
Also used : WordAdapter(com.zhan_dui.dictionary.cursoradapters.WordAdapter) DictionaryDB(com.zhan_dui.dictionary.db.DictionaryDB) ColorDrawable(android.graphics.drawable.ColorDrawable) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) StickyListHeadersListView(com.emilsjolander.components.stickylistheaders.StickyListHeadersListView) Cursor(android.database.Cursor)

Aggregations

Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 StickyListHeadersListView (com.emilsjolander.components.stickylistheaders.StickyListHeadersListView)1 WordAdapter (com.zhan_dui.dictionary.cursoradapters.WordAdapter)1 DictionaryDB (com.zhan_dui.dictionary.db.DictionaryDB)1