小编Asw*_*mar的帖子

AlertDialog样式 - 如何更改标题,消息等的样式(颜色)

我已经突破了这个问题.我需要做的是,AlertDialog在我的Android应用程序中更改所有s 的样式- 对话框背景需要是white-ish,文本需要是black-ish.我尝试创建了很多样式,主题,并从代码,清单等应用,但没有成功,关于内部的文本颜色AlertDialog.现在,我有最简单的代码,设置如下:

表现:

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
Run Code Online (Sandbox Code Playgroud)

styles.xml:

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:alertDialogStyle">@style/DialogStyle</item>
</style>

<style name="DialogStyle" parent="@android:style/Theme.Dialog">
    <!-- changing these background stuff works fine -->
    <item name="android:bottomBright">@android:color/white</item>
    <item name="android:bottomDark">@android:color/white</item>
    <item name="android:bottomMedium">@drawable/dialog_footer_bg</item>
    <item name="android:centerBright">@android:color/white</item>
    <item name="android:centerDark">@drawable/dialog_body_bg</item>
    <item name="android:centerMedium">@android:color/white</item>
    <item name="android:fullBright">@color/orange</item>
    <item name="android:fullDark">@color/orange</item>
    <item name="android:topBright">@color/green</item>
    <item name="android:topDark">@drawable/dialog_header_bg</item>
Run Code Online (Sandbox Code Playgroud)

下面列出的项目不起作用(请阅读我在每个元素上面的评论):

    <!-- panelBackground is not getting set to null, there is something squarish around it -->
    <item name="android:panelBackground">@null</item>

    <!-- Setting this textColor doesn't seem to have any effect at …
Run Code Online (Sandbox Code Playgroud)

android android-theme android-alertdialog android-styles

40
推荐指数
5
解决办法
10万
查看次数

如何检查SharedPreferences文件是否存在

我正在寻找一个Android共享首选项,我想知道有没有办法只检查首选项文件是否存在.

   SharedPreferences  mySharedPreferences ; 
mySharedPreferences=getSharedPreferences(“Name_of_your_preference”,mode);
Run Code Online (Sandbox Code Playgroud)

上面的代码让我相信"Name_of_Your_preferene"存储为一个文件或某种包含您的首选项的容器.

我想知道是否在那里检查是否存在.当用户加载活动时,我想将所有设置保存到此文件中,并带有一些默认值(所有设置均为关闭).但是,如果他们第一次访问该页面,我只想这样做.

否则,如果每次页面加载时我都会这样做

SharedPreferences.Editor editor= mySharedPreferences.edit();

/* now store your primitive type values. In this case it is true, 1f and Hello! World  */

editor.putBolean(“myBoolean”,true);

editor.putFloat(“myFloat”,1f);

editor.putString(“myString”,” Hello! World”);
Run Code Online (Sandbox Code Playgroud)

我猜它会覆盖他们设置的所有设置.

android sharedpreferences

16
推荐指数
3
解决办法
3万
查看次数

如何动态检测我的应用程序是系统还是正常?

如何区分系统应用程序和普通应用程序?我浏览了android PackageManager并找不到任何东西.

编辑:我想通过代码区分.

if(system app) {
  //do something
}
else{
   //do nothing
}
Run Code Online (Sandbox Code Playgroud)

android

10
推荐指数
2
解决办法
6052
查看次数

使用几个AsyncTask或HandlerThread(管道线程)有什么好处?

HandlerThread在应用程序中有一个用于进行不同时间花费操作的好方法,例如,排序或甚至用于处理Web /文件流?什么更适合用于这样的目的:几个AsyncTask,几个Thread或一个HandlerThreadhttp://hi-android.info/src/android/webkit/WebViewWorker.java.html

java android

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

使用 Laravel 将 youtube-dl 输出流式传输到 S3

背景:

我在 Laravel 5.3 上

我正在使用 下载 YouTube 视频youtube-dl,使用Symfony Process

$command = '/usr/local/bin/youtube-dl -o '.$new_file_path.' '.$youtube_id;
$process = new Process($command);
$process->setTimeout(null);
$process->run();
Run Code Online (Sandbox Code Playgroud)

在之后Process的运行,我在预期位置下载的文件。现在我可以将它存储到 S3 如下:

\Storage::disk('s3')->putFile($s3_location, new File($new_file_path));
Run Code Online (Sandbox Code Playgroud)

问题

如您所见,我正在将文件下载到本地存储,然后上传到 S3。如果我可以直接写入 S3,那就太好了。特别是因为两个组件都支持流式处理——Process类可以对输出进行流式处理,而S3 Storage可以存储流,如下:

// Process class supports streamed output
// https://symfony.com/doc/current/components/process.html

// note the '-' after '-o' parameter - it asks youtube-dl to give a stream output, which can be piped in a shell
$process = new Process('/usr/local/bin/youtube-dl -o - '.$youtube_id;);
$process->start();

foreach ($process …
Run Code Online (Sandbox Code Playgroud)

php youtube-dl laravel

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