小编agu*_*ran的帖子

如何在不恢复中间片段的情况下清除Android片段后端堆栈

我需要清除后堆栈中的所有碎片.

问题是我需要确保在某个时间点,堆栈已成功清除,之后不会恢复任何弹出的反向片段.

某些片段显示与当前登录用户相关的内容.现在,如果用户决定退出,我想清除堆栈,注销用户并将应用程序转换为初始片段.问题是,堆栈弹出是延迟的,在我退出后,一些用户相关的片段尝试恢复并询问用户配置文件数据.如果没有登录用户,则底层API会引发异常.因此片段崩溃,因为它不应该在这种状态下使用.

我尝试了很多方法:

@Override
public void onSignOutConfirmed() {
    Log.d(TAG, "onSignOutConfirmed");

    getSupportFragmentManager().popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);

    Log.d(TAG, "onSignOutConfirmed - signing out");

    UserProfileService.signOut();
    Analytics.trackEvent(EventType.SIGN_OUT);
    showStartupScreen();
}
Run Code Online (Sandbox Code Playgroud)

要么

@Override
public void onSignOutConfirmed() {
    Log.d(TAG, "onSignOutConfirmed");

    FragmentManager fm = getSupportFragmentManager();

    int backStackCount = fm.getBackStackEntryCount();

    while(backStackCount-- != 0) {
        fm.popBackStackImmediate();
    }

    Log.d(TAG, "onSignOutConfirmed - signing out");

    UserProfileService.signOut();
    Analytics.trackEvent(EventType.SIGN_OUT);
    showStartupScreen();
}
Run Code Online (Sandbox Code Playgroud)

该日志显示,当我调用UserProfileService.signOut()时,片段仍在处理其生命周期方法.当片段暂停时,取消(使用中断)取消其中一个片段的配置文件数据的AsyncTask.但片段暂停太迟了.

并且错误并不总是如此.但大多数时候它都会出现在三星S2(Android 4.1.2)上.

06-09 19:46:54.760 D/com.myapp.application.MainActivity( 4562): **onSignOutConfirmed**
06-09 19:46:54.765 D/com.myapp.application.screens.main.MainFragment( 4562): onCreateView
06-09 19:46:54.826 D/com.myapp.application.screens.main.MainFragment( 4562): onCreateAnimation (transit 0, enter true, nextAnim 0)
06-09 19:46:54.831 D/com.myapp.application.screens.main.TranscriptionsFragment( …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

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

Android TextView基线相关保证金

我需要确定TextView其基线距离容器底部20dp的方式.

我怎样才能做到这一点?

具有底部边距或填充的布局产生相同的结果.

我想把文字"坐"在紫线上.当我写'坐'时,我的意思是,'wert'应该接触线,而不是'q ... y'.

填充/边距等于紫色方形尺寸:

在此输入图像描述

layout android

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

Android:在英特尔设备上仅运行armeabi应用程序

我正在测试包含一些本机库的应用程序.到目前为止,这些图书馆仅供armeabi拱门使用.用于测试目的的设备是Asus Zenfone 4.它是基于Intel的设备,所以我期待运行应用程序时遇到问题,因为没有x86版本的库.

令人惊讶的是,该应用运行良好.问题是为什么?是因为某种ARM仿真吗?这种仿真适用于所有英特尔Android设备吗?

/ proc/cpuinfo包含以下内容:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 53
model name  : Intel(R) Atom(TM) CPU Z2520  @ 1.20GHz
stepping    : 1
microcode   : 0x110
cpu MHz     : 800.000
cache size  : 512 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fdiv_bug    : no
hlt_bug     : no
f00f_bug    : no …
Run Code Online (Sandbox Code Playgroud)

android arm intel

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

Android不确定进度对话框进度条样式

我找不到Android 22和23之间不确定ProgressDialog中显示的进度条样式的原因.

我们采取一个非常简单的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="example.com.progressbarcolor.MainActivity">

    <Button
        android:id="@+id/show_progress"
        android:text="Show progres"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"/>

    <ProgressBar
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_alignParentBottom="true"
        android:indeterminate="true"
        android:visibility="visible"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

按下按钮显示ProgressDialog:

ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setIndeterminate(false);
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.show();
Run Code Online (Sandbox Code Playgroud)

该应用程序的风格是:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Run Code Online (Sandbox Code Playgroud)

最后是gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "example.com.progressbarcolor"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0" …
Run Code Online (Sandbox Code Playgroud)

android android-theme

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

C++ less运算符使用转换运算符

我无法理解为什么对于以下虚拟类:

class Foo {
public:
    operator double() const {
        return 3.14;
    }
};
Run Code Online (Sandbox Code Playgroud)

当我尝试比较实例时:

Foo f1;
Foo f2;

auto res = f1 < f2;
Run Code Online (Sandbox Code Playgroud)

较少的运营商使用现有的

operator double()const

比较价值时.我在哪里可以找到这种行为的规则?

c++

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

Babel date_format将于2017年返回2016年

我正在尝试显示为指定语言格式化的日期,我很惊讶地看到:

babel.dates.format_date(date(2017,1,1), 'MMM Y')
Run Code Online (Sandbox Code Playgroud)

给出预期值,即:

u'Jan 2017'
Run Code Online (Sandbox Code Playgroud)

而:

babel.dates.format_date(date(2017,1,1), 'MMM Y', locale='fr_FR')
Run Code Online (Sandbox Code Playgroud)

给我:

u'janv. 2016'
Run Code Online (Sandbox Code Playgroud)

为什么2016年不是2017年?

python babel

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

标签 统计

android ×4

android-fragments ×1

android-theme ×1

arm ×1

babel ×1

c++ ×1

intel ×1

layout ×1

python ×1