首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Activity SplashScreen.java中未显示splash.xml中的启动背景

Activity SplashScreen.java中未显示splash.xml中的启动背景
EN

Stack Overflow用户
提问于 2011-11-30 16:01:15
回答 2查看 1.4K关注 0票数 0

当我的应用程序加载图像数据时,我试图显示一个启动/欢迎屏幕,数据加载正常,但splash.xml中的背景图像就是不显示,我在下面发布了我的代码。

代码语言:javascript
运行
复制
public class Splash extends Activity {

 private ChannelDB mDB;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);  
    AppConnect.getInstance(this);

    Thread splashThread = new Thread() {
        @Override
        public void run() {
           try {
               if (tabIsExist(null)==true){
                mDB.Reset();

                   Bitmap bigbang1 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang1);
                   Bitmap bigbang2 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang2);
                   Bitmap bigbang3 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang3);
                   Bitmap bigbang4 = BitmapFactory.decodeResource(getResources(), R.drawable.bigbang4);


                   mDB.createchannelEntry(new ChannelPoster(bigbang1, "生活大爆炸(第一季)" ,"http://appkon.com/hdtvs/channel/bigbang1.xml"  ,"http://movie.douban.com/subject/5372374/" ));
                   mDB.createchannelEntry(new ChannelPoster(bigbang2, "生活大爆炸(第二季)" ,"http://appkon.com/hdtvs/channel/bigbang2.xml"  ,"http://movie.douban.com/subject/3190880/" ));
                   mDB.createchannelEntry(new ChannelPoster(bigbang3, "生活大爆炸(第三季)" ,"http://appkon.com/hdtvs/channel/bigbang3.xml"  ,"http://movie.douban.com/subject/3990470/" ));
                   mDB.createchannelEntry(new ChannelPoster(bigbang4, "生活大爆炸(第四季)" ,"http://appkon.com/hdtvs/channel/bigbang4.xml"  ,"http://movie.douban.com/subject/4804079/" ));

                   }
               }catch (Exception e) {


                       Intent i = new Intent();
                       i.setClassName("com.appkon.hdtvs",
                                      "com.appkon.hdtvs.HDtvs");
                       finish();
                       startActivity(i);
                   }
                finally {

                    Intent i = new Intent();
                    i.setClassName("com.appkon.hdtvs",
                            "com.appkon.hdtvs.HDtvs");
                    finish();
                    startActivity(i);
                }

           }

     };
     splashThread.start();
}

    public boolean tabIsExist(String channelS_TABLE){
        boolean result = false;
        if(channelS_TABLE == null){
                return false;
        }
        Cursor cursor= ChannelDB.check();
        startManagingCursor(cursor);
        try {
                if(cursor.moveToNext()){
                        int count = cursor.getInt(0);
                        if(count>0){
                                result = true;
                        }
                }

        } catch (Exception e) {
            Log.e(this.toString(),"error:"+e.toString());
            Intent intent = new Intent(this,HDtvs.class);  
            startActivity(intent);  
            this.finish(); 
        }                
        return result;
    }


}

这是我的splash.xml

代码语言:javascript
运行
复制
   <?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:background="@drawable/splash">

</LinearLayout>
EN

回答 2

Stack Overflow用户

发布于 2011-11-30 16:25:04

查看制作闪屏simpleadvanced的更好方法

票数 1
EN

Stack Overflow用户

发布于 2012-02-03 23:07:43

first post xD希望这能有所帮助。

您需要编辑AndroidManifest.xml以包括您的启动活动

代码语言:javascript
运行
复制
    <activity android:name=".Splash"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

记住将category设置为LAUNCHER,您的主活动应该如下所示

代码语言:javascript
运行
复制
    <activity android:name=".Main"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="com.anibalismo.sovica.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

不要忘记将Main的类别更改为DEFAULT,并将Main action name更改为"com.anibalismo.sovica.MAIN"……我认为你应该在那里使用你的包名,但不是必须的。

来源:Youtube: thenewboston

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8322768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档