标签: simplecursortreeadapter

带有搜索实现的CursorTreeAdapter

我申请了 我正在使用CursorTreeAdapter作为ExpandableListView.现在我想使用搜索框来显示已过滤的ExpandableListView项.像这样:http://i.imgur.com/8ua7Mkl.png

这是我到目前为止的代码:

MainActivity.java:

package com.example.cursortreeadaptersearch;

import java.util.HashMap;

import android.app.SearchManager;
import android.content.Context;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.provider.ContactsContract;
import android.support.v4.app.LoaderManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.util.Log;
import android.widget.ExpandableListView;
import android.widget.SearchView;
import android.widget.SearchView.OnCloseListener;
import android.widget.SearchView.OnQueryTextListener;

import com.actionbarsherlock.app.SherlockFragmentActivity;

public class MainActivity extends SherlockFragmentActivity {

    private SearchView search;
    private MyListAdapter listAdapter;
    private ExpandableListView myList;

    private final String DEBUG_TAG = getClass().getSimpleName().toString();

    /**
     * The columns we are interested in from the database
     */
    static …
Run Code Online (Sandbox Code Playgroud)

java search android android-cursor simplecursortreeadapter

15
推荐指数
1
解决办法
4022
查看次数

SimpleCursorTreeAdapter导致错误

下面是我的actvity中的代码以及一个内部类,它是Simple Cursor Tree Adapter的一个子类.问题是当我点击"有错误"的子元素时

protected void onStart() {
    super.onStart();
    SQLiteDatabase db = new ToDoDatabase(getApplicationContext())
            .getWritableDatabase();
    Cursor cursor = db.query(true, ToDoDatabase.TABLE_NAME, null, null,
            null, null, null, null, null);
    CustomCursorTreeAdapter cursorTreeAdapter = new CustomCursorTreeAdapter(
            getApplicationContext(), cursor, R.layout.group_item_layout,
            new String[] { ToDoDatabase.TASK_NAME_FORMAT_DATE },
            new int[] { R.id.groupItem }, R.layout.child_item_layout,
            new String[] { ToDoDatabase.TASK_TIME },
            new int[] { R.id.childItem });
    drawerList.setAdapter(cursorTreeAdapter);
}

public class CustomCursorTreeAdapter extends SimpleCursorTreeAdapter {

    public CustomCursorTreeAdapter(Context context, Cursor cursor,
            int groupLayout, String[] groupFrom, int[] groupTo,
            int childLayout, String[] childFrom, int[] …
Run Code Online (Sandbox Code Playgroud)

android simplecursortreeadapter

1
推荐指数
1
解决办法
524
查看次数