这必须经常出现.
当用户在Android应用中编辑首选项时,我希望他们能够在Preference摘要中查看首选项的当前设置值.
示例:如果我有"丢弃旧邮件"的"首选项"设置,该设置指定需要清除邮件的天数.在PreferenceActivity我想让用户看到:
"丢弃旧邮件" < - 标题
" x天后清理消息" < - summary其中x是当前的Preference值
额外的功劳:使这个可重用,所以我可以轻松地将它应用到我的所有首选项,无论其类型如何(这样它可以使用EditTextPreference,ListPreference等,只需最少的编码).
如何删除当前显示的所有Toast消息?
在我的应用程序中,有一个列表,当用户点击某个项目时,会显示一个Toast消息,10个项目--10个Toast消息.
因此,如果用户单击10次,然后按下菜单按钮,他们必须等待几秒钟,直到他们能够读取菜单选项文本.
它应该不是那样的:)
Android新手,我在用户更改首选项时有一些代码我将UI首选项中的"摘要"字段更新为他们输入的值.但是,在创建首选项活动时,我想将"摘要"字段设置为相应首选项中的值.请指教.谢谢.
public class MyPreferenceActivity extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
SharedPreferences sp = getPreferenceScreen().getSharedPreferences();
sp.registerOnSharedPreferenceChangeListener(this);
}
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
Preference pref = findPreference(key);
if (pref instanceof EditTextPreference) {
EditTextPreference etp = (EditTextPreference) pref;
pref.setSummary(etp.getText());
}
}
}
Run Code Online (Sandbox Code Playgroud) 我的问题如下:
我正在向通知栏发布通知,并且我已经在其中发送了一个URI链接.一旦我点击通知我得到一个对话框我想做什么,但它显示垃圾,如应用程序信息,条形码扫描仪,调用对话框.而不是浏览器.
我提出我的代码:
Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
PendingIntent contentIntent = PendingIntent.getActivity(contexta, 0, notificationIntent, 0);
notificationIntent.setData(Uri.parse("http://www.google.com"));
notification.setLatestEventInfo(contexta, contentTitle, contentText, contentIntent);
mNotificationManager.notify(970970, notification);
Run Code Online (Sandbox Code Playgroud)
所以我可能没想到正确的方向.我是否应该插入一个intent并在我自己的应用程序中有一个处理程序而是为浏览器创建一个新的意图?但那会很奇怪,为什么android无法正确处理我的初始意图呢.
一如既往,非常感谢任何和所有的帮助.
谢谢,罗汉.
注意:当我发布这个问题时,我不在我工作的公司工作,因此,即使可能会有一些很好的答案,我实际上也不会测试它们,因为我没有理由 (除了促进社区;这可能导致我有一天这样做).
但是,如果一些解决问题的办法是由许多其他comunity成员提拔,我可能会选择选择它作为问题正确答案经历了这么多年我最初发布这个问题之后.
与此同时,我希望有些答案可能会帮助你们中的一些人遇到这个问题.堆栈溢出!
我们的应用程序必须从在线资源中传播音乐(我不能自由地披露该来源).
为什么在S3上开始流式传输需要2分钟?
由于MEDIA_ERROR_UNKOWN,我已经能够弄清楚Media Player对象进入错误状态 - 很棒.对我帮助不大.因此,在使用OnErrorListener处理onError时,我重置了Media Player对象,然后调用startPlaying来完成剩下的工作 - 设置数据源等.
成员:
private ProgressBar playSeekBar;
private ImageView ivPlay;
private ImageView ivPause;
private ImageView ivBuffer;
private MediaPlayer mPlayer;
private ImageView ivInfo;
private AudioManager audio;
Run Code Online (Sandbox Code Playgroud)
初始化媒体播放器(和Visualizer - 这不是问题的目的)
private void initialMediaPlayerAndVisualizer() {
Log.d(TAG, "Initial Media Player and Visualizer");
playSeekBar = (ProgressBar) findViewById(R.id.progressBar1);
playSeekBar.setMax(100);
playSeekBar.setVisibility(View.GONE);
mPlayer = new MediaPlayer();
Log.d(TAG, "Create onErrorListener");
MediaPlayer.OnErrorListener errorListener = new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int …Run Code Online (Sandbox Code Playgroud) 我已经看过这个主题的一些问题,但当我在我的错误中搜索其他部分时,我没有找到任何内容,所以我决定发布一个完整解释的问题.
我的代码中没有识别错误.无处.添加所有库,成功链接外部库项目.没有任何迹象表明发射会出现任何问题.
然而,当我启动应用程序 - 运行,编译和构建(自动) - 我收到一条弹出消息,指出我的项目包含错误,我应该在尝试再次启动应用程序之前修复它们.
所以我摆弄了一些属性,我的同事发现Android Private Libraries必须检查" " Properties -> Java Build Path -> Order and Export(我之前已经检查过未检查的其他复选框).但是当我运行应用程序时 - 同样弹出,以及Console视图中的以下内容:(可怕的消息)
[2013-06-22 20:55:03 - TheApplication] Dx
trouble processing "java/sql/Savepoint.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not …Run Code Online (Sandbox Code Playgroud) 各位程序员,我对Preferences活动有点问题.
http://developer.android.com/reference/android/preference/PreferenceActivity.html
我只有一个首选项类别和一个listPreference:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
<PreferenceCategory android:title="@string/basic_settings" >
<ListPreference
android:defaultValue="70"
android:entries="@array/listArray"
android:entryValues="@array/listValues"
android:key="updates_interval"
android:persistent="true"
android:summary="@string/SOME_SUMMARY"
android:title="@string/SOME_TITLE" />
</PreferenceCategory>
Run Code Online (Sandbox Code Playgroud)
我需要在listPreference的摘要中写入所选的值(默认值或用户定义的值),例如:我们将至少有70个字符.
我怎么能从代码中做到这一点?
任何帮助表示赞赏
我将一个2岁的项目迁移到Android Studio(以及新的lib),当我调用PreferenceScreen时遇到很多问题.
java.lang.NoSuchFieldError: No static field list_container of type I in class Landroid/support/v7/preference/R$id; or its superclasses (declaration of 'android.support.v7.preference.R$id' appears in /data/app/com.sh.inv-1/base.apk)
at android.support.v7.preference.PreferenceFragmentCompat.onCreateView(PreferenceFragmentCompat.java:260)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1988)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1268)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:754)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1653)
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:364)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:602)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1234)
Run Code Online (Sandbox Code Playgroud)
我的build.gradle是:
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.sh.inv"
targetSdkVersion 23
versionCode 66
versionName "2.5.0"
}
buildTypes {
debug {
}
release {
minifyEnabled true
proguardFiles 'proguard-project.txt'
}
}
productFlavors {
dev { …Run Code Online (Sandbox Code Playgroud) 如何删除帧动画的背景(或将其设置为透明)?
当我将xml布局文件中的背景颜色设置为透明时,运行它时它会变成黑色。
当我setBackgroundColor(0); 在Java 代码中,我收到以下异常:
java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.graphics.drawable.AnimationDrawable
/res/layout/dialog_loading.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background_black_semitransparent" >
<!-- The background of this LinearLayout is so that there is
a semi transparent black overlay over the application content
while the loading animation plays -->
<FrameLayout
android:layout_width="@dimen/dialog_width"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent" >
<ImageView
android:id="@+id/iv_loading"
android:layout_width="@dimen/dialog_width"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:background="@android:color/transparent" />
</FrameLayout>
</LinearLayout> …Run Code Online (Sandbox Code Playgroud) android timer background-color android-animation animationdrawable
如何从通知栏中的通知在我的Android应用程序中启动片段?
我试图实现这个创建我自己的动作然后将动作设置为意图的答案,但我不确定如何使用它以及另外需要什么 - 比如向Manifest添加一些内容.
我有一个通知类,它接收上下文,消息然后是动作.然后,我想过滤该操作以确定要启动的片段,但我不知道如何启动片段而不是启动活动.
这是我的Notifications.java类(不完整):
public class Notifications {
private Context mContext;
public Notifications(Context context) {
this.mContext = context;
}
public static void notify(Context context, String message, String action) {
//Action you invent should include the application package as a prefix — for example: "com.example.project.SHOW_COLOR".
action = "my.package.name.here.frag."+action;
//Construct a user message.
String appName = context.getResources().getString(R.string.app_name);
// Use the Notification manager to send notification
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// Create a notification using android …Run Code Online (Sandbox Code Playgroud) action intentfilter android-notifications android-pendingintent
我正在使用Zend Framework创建一个表单来捕获用户的人口统计信息.我正在努力验证两个文本字段的数字.
我在../application/forms/UserDemographics.php中构建我的表单,如下所示:
class Application_Form_UserDemographics extends Zend_Form
{
public function init()
{
$this->form = new Zend_Form;
$dbAdapter = Zend_Registry::get("db");
...
$this->fax_number = new Zend_Form_Element_Text('fax_number');
$this->fax_number->setLabel('Fax Number')
->addFilter('Int')
->addFilter('StripTags')
->addValidator('Digits');
$this->mobile_number = new Zend_Form_Element_Text('mobile_number');
$this->mobile_number->setLabel('Mobile Number')
->addFilter('Int')
->addFilter('StripTags')
->addValidator('Digits');
...
}
}
Run Code Online (Sandbox Code Playgroud)
我的数据库当前配置如下关于fax_number和mobile_number字段,以便我可以测试是否接受数字:
+-----------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+-------------+------+-----+---------+----------------+
...
| fax_number | varchar(32) | NO | | NULL |
| mobile_number | int(15) | YES | | NULL |
...
Run Code Online (Sandbox Code Playgroud)
当我在zend表单中的任何一个字段中输入任何数字而不是数字时 …
>>>>问题背景<<<<
该项目开始时,我们正在使用Google Apps for Business。这使我们可以将Google Developer Console(https://console.developers.google.com/)与我们的@ company.co.za帐户一起使用,也可以使用我们的@ company.co.za帐户“使用Google登录”。事实证明,Google Developer Project(API密钥所在的位置)是使用前同事的@ company.co.za Google帐户创建的。
从Google Apps for Business迁移到Office 365后,我们失去了使用@ copany.co.za帐户登录Google开发者控制台的功能。到那时,同事已经不在这里工作了,我想这一切都发生得太快了,以至于我们无法确保将所有松散的东西都绑起来。
现在,我们需要将应用程序的开发以及随后所有相关的第三方项目和事物转移到客户端,以进行将来的开发,但是我无法访问Google项目。
这将要求他们在自己的身边创建一个项目,生成新的API密钥以使用Google Maps API等。然后使用新的API密钥更新应用程序(Android和iOS)。
>>>>>这是我的问题<<<<<
但是,这正是我提出的问题所在,这些应用仍在运行,并且可以愉快地访问Google地图。这使我认为该项目必须仍然存在。
我尝试访问Google帮助页面,但是由于我们使用的是青铜色软件包,因此我们只能在其开发人员社区和此处列出的在线文档中找到支持信息:
但我也想在这里问,因为SO的答案非常可靠:)
那么,是否知道该项目是否仍存在于某处?还是我们应该使用新的API密钥创建一个新项目?
google-apps google-maps-api-3 google-cloud-platform google-developer-tools