相关疑难解决方法(0)

使用Fragments进行Android搜索

有人知道一个教程或如何用s 实现标准Android搜索界面的例子Fragment吗?换句话说,是否可以SearchManager在片段中使用标准搜索?

java sqlite android android-searchmanager android-fragments

155
推荐指数
7
解决办法
8万
查看次数

搜索视图的操作栏.反向兼容性问题

我正在构建一个示例应用程序来演示带有过滤器和其他Action Bar项目的SearchView.我能够在4.2(Nexus 7)上成功运行这个应用程序.但它不是在2.3上运行.我用Google搜索了这个问题.来了解我应该使用SherLock Action吧.我刚刚访问http://actionbarsherlock.com/download.html,下载了zip文件,并在视频中添加了库:http://www.youtube.com/watch? v = 4GJ6yY1lNNY&feature = player_embedde由WiseManDesigns提供.但我仍然无法弄清楚这个问题.

这是我的代码:

SearchViewActionBar.java

public class SearchViewActionBar extends Activity implements SearchView.OnQueryTextListener 
{
    private SearchView mSearchView;
    private TextView mStatusView;
    int mSortMode = -1;
    private ListView mListView;
    private ArrayAdapter<String> mAdapter;

    protected CharSequence[] _options = { "Wild Life", "River", "Hill Station", "Temple", "Bird Sanctuary", "Hill", "Amusement Park"};
    protected boolean[] _selections =  new boolean[ _options.length ];


    private final String[] mStrings = Cheeses.sCheeseStrings;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

        setContentView(R.layout.activity_main);

       // …
Run Code Online (Sandbox Code Playgroud)

android actionbarsherlock android-actionbar searchview

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

Actionbarsherlock searchview:setOnQueryTextListener

我正在尝试使用ActionBarSherlock的搜索视图在List中创建一个过滤器.我目前的代码如下:

@Override
public boolean onCreateOptionsMenu(final Menu menu) {
    getSupportMenuInflater().inflate(R.menu.building_search, menu);

    SearchView searchView = new SearchView(getSupportActionBar().getThemedContext());

    SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() 
    {
        public boolean onQueryTextChange(String newText) 
        {
            // this is your adapter that will be filtered
            listAdapter.getFilter().filter(newText);
            return true;
        }

        public boolean onQueryTextSubmit(String query) 
        {
            // this is your adapter that will be filtered
            listAdapter.getFilter().filter(query);
            return true;
        }
    };
    searchView.setOnQueryTextListener(queryTextListener);

    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.search:
            onSearchRequested();
            return true;
    }
    return super.onOptionsItemSelected(item);
} …
Run Code Online (Sandbox Code Playgroud)

android actionbarsherlock searchview

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