1

I'm trying to add a password (I don't it with alertDialog) and a splashscreen (were is my problem) the password works when it asks but before that I get a crash cause of the splashscreen that dosen't work.

I made a XML file for the splashscreen

<?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>  

And when I try to add the command to get the splashscreen in the main program

  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();
                }

I get this crash

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'

So what am I doing wrong? The purpose of the splashscreen is that I want to be behind the AlertDialog and in front of what's in the back so the user if dosen't know the password can't see what's behind that ( I did with setView but that works only on linearLayout and not on PrefferenceScreen

The complete 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
Peter O.
  • 32,158
  • 14
  • 82
  • 96
Mircea Mihai
  • 167
  • 1
  • 13

1 Answers1

2

What I can tell from 1 line crash output is, you are having a ListActivity. And you have not given the ListView id as @android:id/list.

Give listview id as

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

And your problem would be solved. Hope it helps.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124
  • Thank you for the fast response, but that's my problem i don't know were exacly it refferes to that listView – Mircea Mihai Apr 12 '13 at 12:55
  • @MirceaMihai Have you any listactivity? The file being set in that activity must be containing one listview, right? Its Id should be changed. – MysticMagicϡ Apr 12 '13 at 12:59
  • Thats the funny thing that the app dosen't have. What i done is that i add this -> setContentView(R.layout.splashscreen); – Mircea Mihai Apr 12 '13 at 13:03
  • And the splashscreen.xml contains this -> – Mircea Mihai Apr 12 '13 at 13:04
  • That's strange. Can you edit your question to contain full logcat output and SplashScreen.java 's code? @MirceaMihai – MysticMagicϡ Apr 12 '13 at 13:06
  • @MirceaMihai And make sure you have not extended ListActivity by mistake. – MysticMagicϡ Apr 12 '13 at 13:09
  • Well i searched the code (the project dosen't belong to me what i want to change to the actual code to add a password request and a splashscreen ) The part with the password i done... in exchange the problem is with the splashscreen Thank you for the help you gave me till now, hope you can guide me somehow cause i'm spending almost a week on it hehe – Mircea Mihai Apr 12 '13 at 13:16
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/28111/discussion-between-thereader-and-mircea-mihai) – MysticMagicϡ Apr 12 '13 at 13:33