在Metro,我可以知道你如何等待线程完成.在传统的桌面应用程序中,要等待线程完成,我将使用
thread.Join()
但是,地铁怎么样?
// public void getSignalProcessingRunnable(IAsyncAction source) {}
IAsyncAction ThreadPoolWorkItem = Windows.System.Threading.ThreadPool.RunAsync(getSignalProcessingRunnable);
// How to wait for thread to complete?
Run Code Online (Sandbox Code Playgroud)
使用await不起作用.
我指的是http://timheuer.com/blog/archive/2012/08/07/updated-how-to-using-sqlite-from-windows-store-apps.aspx和http://wp.qmatteoq. COM /使用-sqlite的-在你的窗户-8 Metro风格的应用程序/
据我所知,sqlite-net对外键没有很好的支持.因此,我没有创建一个映射到表的类,而是使用以下方式创建表.
public static readonly String PROFILE_TABLE_CREATE = "create table if not exists "
+ PROFILE_TABLE_NAME + "("
+ COLUMN_PROFILE_ID + " integer primary key autoincrement, "
+ COLUMN_TIMESTAMP + " integer not null, "
+ COLUMN_PROFILE_NAME + " text not null, "
+ COLUMN_AGE + " integer not null, "
+ COLUMN_GENDER + " integer not null"
+ ");";
private async void CreateDatabase()
{
SQLiteAsyncConnection conn = new SQLiteAsyncConnection(DATABASE_NAME);
await conn.ExecuteAsync(PROFILE_TABLE_CREATE); …Run Code Online (Sandbox Code Playgroud) 以前,我们没有问题显示以下内容 DialogFragment

// Triggered by button click.
private void openFromCloud() {
LoadFromCloudTaskFragment loadFromCloudTaskFragment = new LoadFromCloudTaskFragment();
FragmentManager fm = this.getSupportFragmentManager();
fm.beginTransaction().add(loadFromCloudTaskFragment, "loadFromCloudTaskFragment").commit();
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我们DialogFragment在按下下面的OK按钮后显示相同的内容Intent,则会发生错误.

private void openFromCloud() {
startActivityForResult(Utils.getGoogleAccountCredential().newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
switch (requestCode) {
case REQUEST_ACCOUNT_PICKER:
if (resultCode == RESULT_OK && data != null && data.getExtras() != null) {
String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
if (accountName != null) {
Utils.getGoogleAccountCredential().setSelectedAccountName(accountName);
LoadFromCloudTaskFragment loadFromCloudTaskFragment = new …Run Code Online (Sandbox Code Playgroud) 我为动作栏按钮尝试了两种不同的进度条样式
refreshMenuItem.setActionView(R.layout.actionbar_indeterminate_progress);
Run Code Online (Sandbox Code Playgroud)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?attr/actionButtonStyle" >
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/Widget.ProgressBar.Small" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我曾尝试过Widget.ProgressBar.Small和Widget.ProgressBar.Small.Inverse.但是,我没有看到任何视觉差异.


我希望颜色有反转,但没有.我错过了什么吗?
有没有免费的方法可以从应用程序发送电子邮件,而不会出现“可疑登录被阻止”的情况?
目前,我正在创建一个虚拟 GMail 帐户,以使用以下描述的方式从我的应用程序发送电子邮件:/sf/answers/255440391/
但是,有时,由于我的应用程序用户来自不同位置的大量使用,某些消息将无法发送。我从 Google 收到以下消息:
嗨,xxx,
最近有人尝试使用应用程序登录您的 Google 帐户 - xxx@gmail.com。
我们阻止了登录尝试,以防劫持者试图访问您的帐户。请检查登录尝试的详细信息:
我是否可以尝试其他方法,以便我始终可以从我的应用程序成功发送电子邮件?
通过使用以下.htaccess
RewriteEngine On
RewriteRule ^([0-9]+)/([0-9]+)$ /api/web/index.html#$1/$2 [R=301,NC,L]
Run Code Online (Sandbox Code Playgroud)
用户在浏览器中键入以下URL时.
http://localhost:8080/1/2
Run Code Online (Sandbox Code Playgroud)
我期待,Apache将执行内部重定向,并在浏览器中更改显示的URL(通过R = 301).
http://localhost:8080/api/web/index.html#1/2
Run Code Online (Sandbox Code Playgroud)
在浏览器中更改显示的URL非常重要.这是为了确保index.htmlJavaScript可以正确解析url.
但是,我真正得到的是
http://localhost:8082/api/web/index.html%231/2
Run Code Online (Sandbox Code Playgroud)
我会得到Apache错误.
Apache错误认为,我希望获取一个名为2目录的文件api/web/index.html%231/
有什么我可以通过.htaccess仅修改来解决这个问题吗?
目前,我正在实现具有以下签名的方法
public static double Newtons_method(double[] payments, double[] days, double guess)
有时,计算将失败.有几种方法可以指示失败.
Double,并返回null.Double.NaN并使用Double.isNaN(double)它来测试它.但是,有几个问题.
Double使用的话,我需要做很多盒子和拆箱.try catch使代码看起来很混乱.不是,在Newtons_method这种算法失败的情况下有很多常见的情况.因此,可能不适合将它们视为exception第三种方法怎么样,回归Double.NaN?这是一个好的做法吗?
这是您参考的源代码.
https://github.com/yccheok/xirr/blob/master/src/org/yccheok/quant/XIRR.java#L56
请注意,尚未执行任何错误检查.因此,err可能永远不会进一步减少,并且该方法可能会进入无限循环.
我遇到了"回文"的概念.我试着通过阅读维基百科来理解
http://en.wikipedia.org/wiki/Palindrome#Computation_theory
该段引起了我的注意
这意味着具有有限内存量的计算机不可能一次性可靠地测试回文.
我想测试一个给定的字符串是否是"回文"是非常直接的?我出了一个快速的代码.
public class Utils {
private static final String SPECIAL_CHARACTERS_REGEX = "[\\s!,]";
private static String removeSpecialCharacters(String string) {
return string.replaceAll(SPECIAL_CHARACTERS_REGEX, "");
}
public static boolean isPalindrome(String string) {
String str = string.toLowerCase();
str = removeSpecialCharacters(str);
if (str.isEmpty()) {
return false;
}
int head = 0;
int tail = str.length() - 1;
while (head < tail) {
char h = str.charAt(head);
char t = str.charAt(tail);
if (h != t) {
return false;
}
head++;
tail--;
}
return …Run Code Online (Sandbox Code Playgroud) 我尝试通过使用以下XML将水平进度条放在工具栏的顶部.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Toolbar -->
<include layout="@layout/toolbar"/>
<!-- http://stackoverflow.com/questions/14171471/remove-vertical-padding-from-horizontal-progressbar -->
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:id="@+id/progress_bar"
android:layout_gravity="top"
android:layout_marginBottom="0dp"
android:layout_marginTop="-3dp"
android:progress="2000"
android:max="10000" />
</FrameLayout>
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="8dp"
android:id="@+id/progress_bar2"
android:layout_gravity="top"
android:layout_marginBottom="0dp"
android:layout_marginTop="-3dp"
android:progress="2000"
android:max="10000" />
</FrameLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<!-- android:elevation="4dp" is used due to http://www.google.com/design/spec/what-is-material/elevation-shadows.html#elevation-shadows-elevation-android- -->
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
这在Android 4+下运行得非常好.这是Android 4+的屏幕截图
但是,当涉及到Android 5+时,工具栏顶部不会显示水平进度条.
如果我删除线 …
我有以下方法,它扩大了第一个字符TextView.
private void makeFirstLetterBig(TextView textView, String title) {
final SpannableString spannableString = new SpannableString(title);
int position = 0;
spannableString.setSpan(new RelativeSizeSpan(2.0f), position, position + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
//textView.setText(spannableString.toString());
textView.setText(spannableString, BufferType.SPANNABLE);
}
Run Code Online (Sandbox Code Playgroud)
这是TextView正在使用的.
<TextView
android:id="@+id/title_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:textColor="?attr/newsTitleTextViewSelector"
android:duplicateParentState="true"
android:text="TextView" />
Run Code Online (Sandbox Code Playgroud)
这是Marshmallow 6之前的结果.
它看起来很漂亮,因为当文本内容包装到第二行时,大的第一个字符不会影响第二行.
但是,当在Marshmallow 6中运行相同的应用程序时,我得到以下结果.
看起来,大字"我"正在为整个文本内容创建一个大填充.这导致第二行(与亚马逊)与第一行有一个巨大的行间距.
我可以知道,我怎样才能在棉花糖6中避免这样的问题?我希望得到与棉花糖之前相同的结果.
p/s我也在https://code.google.com/p/android/issues/detail?id=191187上提交了一份报告.
2015年12月9日,Google已修复此问题,并将在Android 6.0.1中发布 - https://code.google.com/p/android/issues/detail?id=191187