有什么办法把演员从preferences意图是什么? [英] Is there any way to put extras to Intent from preferences?

查看:132
本文介绍了有什么办法把演员从preferences意图是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是从发射preferences屏幕活动。活动是在三个preferences共享。 我不知道是否可以设置额外的这项活动在XML

Hi i'm launching activity from preferences screen. Activity is shared among three preferences. I wonder if i can set extras for this activity in xml

<Preference
    android:key="action_1"
    android:title="@string/action_1_title"
>
    <intent
        android:action="com.package.SHAREDACTION"
    >

    </intent>
</Preference>

我不知道是否可以这样做

i wonder if i can do something like

<extras>
     <item
      android:name=""
      android:value=""/>
</extras>

我需要做的整数关口真的。我可以在不同的行动和检查行动,而不是演员。

All i need to do to pass an integer really. I can different actions and check action instead of extras.

推荐答案

随着演员不是常数,你应该通过他们在Java code,而不是XML。

As your extras are not constants, you should pass them in the java code instead of xml.

Intent intent = new Intent( this, YourTargetActivity.class );
intent.putExtra( EXTRAS_KEY, extras );
yourPref.setIntent( intent );

这篇关于有什么办法把演员从preferences意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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