小编Dev*_*wal的帖子

widget.SearchView没有在android中显示用于语音搜索的MIC按钮

我在名为activity_products_final的布局文件中有一个seachview

    <android.support.v7.widget.SearchView
        android:id="@+id/searchView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:queryHint="Search..">
    </android.support.v7.widget.SearchView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

活动:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_products_final);



    searchView = (android.support.v7.widget.SearchView) findViewById(R.id.searchView);
    searchView.setIconified(false);
    searchView.onActionViewExpanded();
    searchView.clearFocus();
    searchView.setOnQueryTextListener(new android.support.v7.widget.SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (adapter != null)
                filterData(query);
            return false;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            if (adapter != null)
                filterData(query);
            return false;
        }
    });



    ImageView closeButton = (ImageView) searchView.findViewById(R.id.search_close_btn);
    closeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            searchView.setQuery("", false);
            searchView.clearFocus();
            //collapseAll();
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

清单文件

<activity

    android:name=".ActivityProductList"
    android:configChanges="orientation|screenSize" …
Run Code Online (Sandbox Code Playgroud)

android

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

Angular .controller()在.run()AngularJS之前运行

我在.run()中有一个ajax调用,它将一个变量加载到$ rootScope中.在与视图关联的控制器中需要该变量.有时在.controller加载时刷新(F5)时,$ rootScope.SuperCategories中没有任何内容.

sampleApp.factory('SuperCategoryService', ['$http', '$q', '$rootScope', function ($http, $q, $rootScope){

    var SuperCategoryService =  {};
    SuperCategoryService.SuperCategories = $rootScope.SuperCategories;
    alert ($rootScope.SuperCategories);
    return SuperCategoryService;

}]);



sampleApp.run(function($rootScope, $q, $http) {

    var req = {
        method: 'POST',
        url: 'SuperCategoryData.txt',
        //url: 'http://localhost/cgi-bin/superCategory.pl',
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }//,
        //data: { action: 'GET' }
    };


    $rootScope.SuperCategories = [];

    $rootScope.GetSuperCategories = function () {

        var defer = $q.defer();
        $http(screq).then(function(response) {
            $rootScope.SuperCategories = response.data;
            //alert ($rootScope.SuperCategories);
            defer.resolve($rootScope.SuperCategories);
        }, function(error) {
            defer.reject("Some error");
        });
        return defer.promise;
    }

    $rootScope.GetSuperCategories();


});
Run Code Online (Sandbox Code Playgroud)

如何解决这个bug.

angularjs

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

angularJS中$ q.when和$ q.defer之间的差异

我看到angularJS文件,在某些地方,评论者评论了这3行:

var deferred = $q.defer();
deferred.resolve(BrandList);
return deferred.promise;
Run Code Online (Sandbox Code Playgroud)

并替换为这一个:

return $q.when(BrandList);
Run Code Online (Sandbox Code Playgroud)

我想了解两者之间的区别.两者都有同样的目的吗?哪个应该用?

javascript angular-promise

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

如何更改按钮android中的图标大小

我有一个既有文本又有图像的按钮。它所取的图像尺寸作为图像的实际尺寸。如何更改按钮中图像的大小?

<Button
    android:id="@+id/button3"
    android:layout_weight="1"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:drawableTop="@drawable/home_icon"
    android:text="Settings"
    />
Run Code Online (Sandbox Code Playgroud)

android

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

ExpandableRecyclerAdapter如何在展开项目时强制项目向上移动

这是我的ExpandableRecyclerAdapter适配器

public class MyAdapter extends ExpandableRecyclerAdapter<MyAdapter.ProductParentViewHolder, MyAdapter.ProductChildViewHolder> {

    private LayoutInflater mInflater;
    private Context context;
    private List<? extends ParentListItem> mParentItemList;

    public MyAdapter(Context context, List<ParentListItem> itemList) {
        super(itemList);
        mInflater = LayoutInflater.from(context);
        this.context = context;
        this.mParentItemList = itemList;
    }

    @Override
    public ProductParentViewHolder onCreateParentViewHolder(ViewGroup viewGroup) {
        View view = mInflater.inflate(R.layout.list_item_crime_parent, viewGroup, false);
        return new ProductParentViewHolder(view);
    }

    @Override
    public ProductChildViewHolder onCreateChildViewHolder(ViewGroup viewGroup) {
        View view = mInflater.inflate(R.layout.list_item_crime_child, viewGroup, false);
        return new ProductChildViewHolder(view);
    }

    @Override
    public void onBindParentViewHolder(ProductParentViewHolder crimeParentViewHolder, int i, ParentListItem parentListItem) {
        Product product …
Run Code Online (Sandbox Code Playgroud)

android

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

如何通过点击应用邀请链接来了解被邀请者是否第一次安装应用

获得应用邀请后,被邀请者点击链接.根据已经安装的应用程序,他将被引导到app store,最后来到处理AppInite链接的Actiity.

我的深层链接看起来像这样:http: //example.com/app-invite/

其中user_id是注册用户的id(在我的后端服务器中).我能够获得用户的正确ID.

这是处理深层链接的代码.

private void processReferralIntent(Intent intent) {
    String invitationId = AppInviteReferral.getInvitationId(intent);
    String deepLink = AppInviteReferral.getDeepLink(intent);
    String userId = deepLink.substring(deepLink.lastIndexOf("/") + 1);
    Utility.displayToast("userid " + userId);


    // Handle the deep link. For example, open the linked
    // content, or apply promotional credit to the user's
    // account.

    Log.d(TAG, "Found Referral: " + invitationId + ":" + deepLink);
    ((TextView) findViewById(R.id.deep_link_text))
            .setText(getString(R.string.deep_link_fmt, deepLink));
    ((TextView) findViewById(R.id.invitation_id_text))
            .setText(getString(R.string.invitation_id_fmt, invitationId));
}
Run Code Online (Sandbox Code Playgroud)

现在,如果这是被邀请者第一次安装应用程序,点击应用邀请链接,我想给被邀请者和邀请者一些促销信用.

我怎么知道这是第一次?甚至应用程序安装alredy processReferralIntent()将被调用.

firebase firebase-invites

6
推荐指数
0
解决办法
333
查看次数

无法解析android中的dagger组件的符号

我正在尝试将Dagger2添加到Android Studio中的项目中.

这是我的依赖.

compile 'com.google.dagger:dagger:2.8'
annotationProcessor 'com.google.dagger:dagger-compiler:2.8'
provided 'javax.annotation:jsr250-api:1.0'
Run Code Online (Sandbox Code Playgroud)

我正在关注这个例子.

https://guides.codepath.com/android/Dependency-Injection-with-Dagger-2#advantages
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误.

无法解析符号DaggerNetComponent

我尝试更改依赖关系和谷歌搜索后找到的其他解决方案.但没有运气.

谁可以帮我这个事?

android dagger-2

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

如何在c ++中使用默认构造函数初始化变量

给出教程中的以下函数模板.

template<class T>
double GetAverage(T tArray[], int nElements)
{
    T tSum = T(); // tSum = 0

    for (int nIndex = 0; nIndex < nElements; ++nIndex)
    {
        tSum += tArray[nIndex];
    }

    // Whatever type of T is, convert to double
    return double(tSum) / nElements;
}
Run Code Online (Sandbox Code Playgroud)

在线

T tSum = T(); // tSum = 0
Run Code Online (Sandbox Code Playgroud)

他们说它将调用特定类型的默认构造函数(基于我们称之为此函数的类型).我怀疑这个调​​用是如何将值赋给tSum的,因为这会调用构造函数.但由于构造函数不返回任何内容,iSum如何初始化为0表示int或0.0表示double.

c++ templates

5
推荐指数
2
解决办法
1101
查看次数

如何在Perl中为JSON数组指定名称

在我的脚本to_json()中以json格式转换loop_data并分配给$ json.

my $json = to_json(\@loop_data);
print $json;
Run Code Online (Sandbox Code Playgroud)

给出了这个输出.

[
    {
        "Name": "Vivek",
        "Age": 20
    },
    {
        "Name": "Sonali",
        "Age": 19
    }
]
Run Code Online (Sandbox Code Playgroud)

但不是我想要打印$ json来提供此输出.

{"Friends" : [
    {
        "Name": "Vivek",
        "Age": 20
    },
    {
        "Name": "Sonali",
        "Age": 19
    }
]}
Run Code Online (Sandbox Code Playgroud)

在哪里添加"朋友"和{}.

perl json

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

android expandablelistview,只在单击组指示器时展开视图,如果点击任何地方,则打开新活动,但groupindicator

我的Activity上有一个ExpandableListView,其中group包含图像和名称,而child包含group(name,id等)的变体.无论我单击展开/折叠按钮,还是单击组中的任何位置,它都会一直展开/折叠.我想要的是,只有当用户点击指标时,才会展开/折叠列表.我怎样才能做到这一点?为了单击TextView,我想打开不同的活动.不幸的是,OnGroupClickListener不提供此信息.

谁可以帮我这个事?

谢谢

android expandablelistview

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