Android的自定义动作条与搜索查看 [英] Android Custom ActionBar with Search View

查看:135
本文介绍了Android的自定义动作条与搜索查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的自定义动作条库在我的Andr​​oid应用程序。在那里,我想显示搜索查看,但无法找到任何解决方案,即时通讯在图书馆的工作是
https://github.com/johannilsson/android-actionbar

这是一类

I am using custom ActionBar library in my Android App. there i want to show a searchView but can not find any solution, i m working in library that is
https://github.com/johannilsson/android-actionbar

This is a class

private class ExampleAction extends AbstractAction {

        public ExampleAction() {
            super(R.drawable.ic_title_export_default);
        }

        @Override
        public void performAction(View view) {
            Toast.makeText(OtherActivity.this, "Example action",
                    Toast.LENGTH_SHORT).show();
        }

    }
    //use for signle action how to use for multiactions
       ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
       actionBar.addAction(new ExampleAction());



其实我发现code的搜索栏,但它是在的.cs格式如何使用这个搜索查看
https://github.com/zleao/MonoDroid.ActionBar

感谢兄弟和放大器; SIS

actually i found code for searchbar but it is in .cs format how to use this searchview
https://github.com/zleao/MonoDroid.ActionBar

Thanks bro & sis

推荐答案

看看这个<一href="http://stackoverflow.com/questions/18288724/searchview-on-support-v7-appcompat-library-issue-default-9-patch-background-not">answer. 根据这个答案搜索查看可支持库。 添加依赖于 build.gradle

Take a look at this answer. According to this answer SearchView is available support library. add dependency to build.gradle

compile 'com.android.support:appcompat-v7:22.0.0'

和使进口

进口android.support.v7.app.ActionBarActivity;  进口android.support.v7.widget.SearchView;

import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView;

根据这个答案,它的工作的API 8模拟器。欲了解更多详情,请向问题的环节和答案本身。 希望它能帮助。

According to this answer it worked on API 8 on emulator. For more details, check the link with the question and answer itself. Hope it helps.

更新

通过添加此code

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:hmkcode="http://schemas.android.com/apk/res-auto">
<item
    android:id="@+id/action_search"
    android:orderInCategory="100"
    hmkcode:showAsAction="always"
    android:icon="@drawable/ic_action_search"
    android:title="Search"/>
<item
    android:id="@+id/action_copy"
    android:orderInCategory="100"
    hmkcode:showAsAction="always"
    android:icon="@drawable/ic_content_copy"
    android:title="Copy"/>
<item
    android:id="@+id/action_share"
    android:orderInCategory="100"
    hmkcode:showAsAction="always"
    android:icon="@drawable/ic_social_share"
    android:title="Share"/>

您可以实现这一点:

您可以自定义你想要的方式的项目。欲了解更多详情,请参阅此例如

You can customize items in the way you want. For more details see this example.

这篇关于Android的自定义动作条与搜索查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆