【问题标题】:Android splashscreen and passwordAndroid启动画面和密码
【发布时间】:2013-04-12 12:39:03
【问题描述】:

我正在尝试添加密码(我不使用 alertDialog)和闪屏(这是我的问题)密码在询问时有效,但在此之前我得到了闪屏的崩溃原因工作。

我为启动画面制作了一个 XML 文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_height="fill_parent" 
android:layout_width="fill_parent" 
android:orientation="vertical" 
xmlns:android="http://schemas.android.com/apk/res/android">  
<ImageView android:id="@+id/splashscreen" 
android:layout_gravity="center" 
android:layout_height="fill_parent" 
android:layout_width="wrap_content" 
android:src="@drawable/untitled">  
</ImageView></LinearLayout>  

当我尝试在主程序中添加命令以获取启动画面时

  AlertDialog.Builder alert = new AlertDialog.Builder(this);                 
    alert.setTitle("Login");  
    alert.setMessage("Enter Pin :");  
    alert.setCancelable(false);

    setContentView(R.layout.splashscreen);

     // Set an EditText view to get user input   
     final EditText input = new EditText(this); 
     alert.setView(input);

        alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {  
        public void onClick(DialogInterface dialog, int whichButton) {  
            String value = input.getText().toString();
            String compar = "123456";
                if(value.equals(compar))
                {
                    Log.d( TAG, "Pin Value : " + value);
                   copiezmView.setVisibility(View.VISIBLE);
                }    
                else
                {
                    Toast.makeText(getApplicationContext(), "Acces Denied", Toast.LENGTH_SHORT).show();
                    alerta();
                }

我遇到了这个崩溃

java.lang.RuntimeException: Unable to start activity ComponentInfo{///////}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

那我做错了什么?闪屏的目的是我想在 AlertDialog 后面和后面的东西前面,这样用户如果不知道密码就看不到后面的内容(我用 setView 做过,但这只适用于 linearLayout而不是在 PreferenceScreen

完整的logCat

04-12 13:09:49.734: E/AndroidRuntime(1731): FATAL EXCEPTION: main
04-12 13:09:49.734: E/AndroidRuntime(1731): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.zegoggles.smssync/com.zegoggles.smssync.SmsSync}:    java.lang.RuntimeException: Your content must have a ListView whose id attribute is   'android.R.id.list'
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.os.Looper.loop(Looper.java:137)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.ActivityThread.main(ActivityThread.java:5039)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at java.lang.reflect.Method.invokeNative(Native Method)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at    java.lang.reflect.Method.invoke(Method.java:511)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at dalvik.system.NativeStart.main(Native Method)
04-12 13:09:49.734: E/AndroidRuntime(1731): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.ListActivity.onContentChanged(ListActivity.java:243)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.preference.PreferenceActivity.onContentChanged(PreferenceActivity.java:959)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:273)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.Activity.setContentView(Activity.java:1881)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at com.zegoggles.smssync.SmsSync.alerta(SmsSync.java:132)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at com.zegoggles.smssync.SmsSync.onCreate(SmsSync.java:118)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at android.app.Activity.performCreate(Activity.java:5104)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-12 13:09:49.734: E/AndroidRuntime(1731):     at       android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-12 13:09:49.734: E/AndroidRuntime(1731):     ... 11 more

【问题讨论】:

  • 请添加整个logcat。
  • @Torcellite 我添加了它,希望它有所帮助,因为我没有想法。 - NikedLab 感谢您的提示,我阅读了它,但不幸的是它对我的问题没有帮助,但谢谢您

标签: android passwords splash-screen


【解决方案1】:

我可以从 1 行崩溃输出中看出,您有一个 ListActivity。而且您还没有将ListView id 指定为@android:id/list

将列表视图 ID 设为

android:id="@android:id/list"

你的问题就解决了。希望对您有所帮助。

【讨论】:

  • 感谢您的快速响应,但这是我的问题,我不知道它是否与该列表视图有关
  • @MirceaMihai 你有任何列表活动吗?在该活动中设置的文件必须包含一个列表视图,对吗?它的 ID 应该改变。
  • 这就是应用程序没有的有趣之处。我所做的是我添加了这个 -> setContentView(R.layout.splashscreen);
  • 而 splashscreen.xml 包含这个 -> schemas.android.com/apk/res/android">
  • 这很奇怪。您可以编辑您的问题以包含完整的 logcat 输出和 SplashScreen.java 的代码吗? @MirceaMihai
猜你喜欢
  • 1970-01-01
  • 2021-12-26
  • 1970-01-01
  • 2015-06-21
  • 2020-06-15
  • 2020-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多