Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 带有ProgesBar的启动屏幕_Android_Mono_Xamarin.android - Fatal编程技术网

Android 带有ProgesBar的启动屏幕

Android 带有ProgesBar的启动屏幕,android,mono,xamarin.android,Android,Mono,Xamarin.android,可能重复: 我可以使用主题为我的应用程序创建一个简单的启动屏幕,而且效果很好。但是,有时应用程序可能需要刷新大量数据,我想向用户显示一个进度条,让他们在等待时知道发生了什么。因此,我放弃了主题,创建了一个布局资源,并将其设置为我的Splash活动的ContentView,但没有显示任何内容。我的内容不仅没有显示(完全黑屏),而且标题栏也会继续显示,尽管我尽可能地隐藏它 Splash.axml <?xml version="1.0" encoding="utf-8"?> <Li

可能重复:

我可以使用主题为我的应用程序创建一个简单的启动屏幕,而且效果很好。但是,有时应用程序可能需要刷新大量数据,我想向用户显示一个进度条,让他们在等待时知道发生了什么。因此,我放弃了主题,创建了一个布局资源,并将其设置为我的Splash活动的ContentView,但没有显示任何内容。我的内容不仅没有显示(完全黑屏),而且标题栏也会继续显示,尽管我尽可能地隐藏它

Splash.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:gravity="center">
<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="15dp"
    android:src="@drawable/logo" />
<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center">
    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="10dp" />
    <TextView
        android:id="@+id/progressText"
        android:text="Loading..."
        android:textSize="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dp" />
</LinearLayout>
仍然在标题栏中显示徽标和标题,内容完全没有显示任何内容。甚至尝试将所有AsyncTask和StartActivity的内容都去掉,只是尝试用splash布局加载活动。它最终还是会出现,但它首先会在很长一段时间内以黑屏的形式出现。无法想象为什么这是我的主要启动程序,除了设置活动的内容,实际上什么都没有

至于出现的标题栏,我也尝试将其添加到我的清单中(我目前正在另一个活动中工作,很好)



如果我为活动添加了主题,标题栏就会消失,但我的布局资源永远不会显示

你难道不知道,经过一整天的努力,我在发帖几分钟后就解决了大部分问题。简言之,我将主题放回了Splash活动中,该活动现在显示在所有内容最初加载时,并且通常在内容设置之前重定向到登录,这非常完美。但我将OnCreate更改如下:

[Activity(MainLauncher=true, NoHistory = true,  ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape, Theme = "@style/Theme.Splash")]
public class Splash : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        RequestWindowFeature(WindowFeatures.NoTitle);

        Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

        SetContentView(Resource.Layout.Splash);

        string lastUpdated = PreferenceManager.GetDefaultSharedPreferences(this).GetString("LastInventoryUpdate", null);

        DateTime lastUpdateDate = Convert.ToDateTime(lastUpdated);

        TimeSpan span = DateTime.Today - lastUpdateDate;

        if (string.IsNullOrEmpty(lastUpdated) || span.Days > 30)
        {
            SetTheme(Resource.Drawable.bg_black);
            TextView progressText = (TextView) FindViewById(Resource.Id.progressText);
            progressText.Text = "Updating parts database.  May take several minutes...";
            InventoryRepository repository = ((MyApp) Application).Inventory;
            repository.Execute();
        }
        else
            StartActivity(typeof (Login));
    }
}

主要区别在于,我只在不运行异步任务的情况下调用StartActivity。否则,我将从AsyncTask的OnPostExecute调用StartActivity。另外,请确保在初始布局中设置所有视图的背景属性。因为我在活动中留下了主题,如果您不这样做,您的主题将显示为每个视图的背景

你难道不知道,经过一整天的努力,我在发帖几分钟后就解决了大部分问题。简言之,我将主题放回了Splash活动中,该活动现在显示在所有内容最初加载时,并且通常在内容设置之前重定向到登录,这非常完美。但我将OnCreate更改如下:

[Activity(MainLauncher=true, NoHistory = true,  ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape, Theme = "@style/Theme.Splash")]
public class Splash : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        RequestWindowFeature(WindowFeatures.NoTitle);

        Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

        SetContentView(Resource.Layout.Splash);

        string lastUpdated = PreferenceManager.GetDefaultSharedPreferences(this).GetString("LastInventoryUpdate", null);

        DateTime lastUpdateDate = Convert.ToDateTime(lastUpdated);

        TimeSpan span = DateTime.Today - lastUpdateDate;

        if (string.IsNullOrEmpty(lastUpdated) || span.Days > 30)
        {
            SetTheme(Resource.Drawable.bg_black);
            TextView progressText = (TextView) FindViewById(Resource.Id.progressText);
            progressText.Text = "Updating parts database.  May take several minutes...";
            InventoryRepository repository = ((MyApp) Application).Inventory;
            repository.Execute();
        }
        else
            StartActivity(typeof (Login));
    }
}
主要区别在于,我只在不运行异步任务的情况下调用StartActivity。否则,我将从AsyncTask的OnPostExecute调用StartActivity。另外,请确保在初始布局中设置所有视图的背景属性。因为我在活动中留下了主题,如果您不这样做,您的主题将显示为每个视图的背景

[Activity(MainLauncher=true, NoHistory = true,  ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape, Theme = "@style/Theme.Splash")]
public class Splash : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        RequestWindowFeature(WindowFeatures.NoTitle);

        Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

        SetContentView(Resource.Layout.Splash);

        string lastUpdated = PreferenceManager.GetDefaultSharedPreferences(this).GetString("LastInventoryUpdate", null);

        DateTime lastUpdateDate = Convert.ToDateTime(lastUpdated);

        TimeSpan span = DateTime.Today - lastUpdateDate;

        if (string.IsNullOrEmpty(lastUpdated) || span.Days > 30)
        {
            SetTheme(Resource.Drawable.bg_black);
            TextView progressText = (TextView) FindViewById(Resource.Id.progressText);
            progressText.Text = "Updating parts database.  May take several minutes...";
            InventoryRepository repository = ((MyApp) Application).Inventory;
            repository.Execute();
        }
        else
            StartActivity(typeof (Login));
    }
}