0

I just change highscores.xml but suddenly I've got some strange error when i try to choose Highscores in menu. LogCat

12-20 20:30:23.972: INFO/ActivityManager(58): Displayed activity game.main/game.mainmenu.MainMenuActivity: 2166 ms (total 101457 ms)
12-20 20:30:29.172: DEBUG/dalvikvm(123): GC_EXPLICIT freed 893 objects / 48888 bytes in 143ms
12-20 20:30:34.233: DEBUG/dalvikvm(197): GC_EXPLICIT freed 93 objects / 8144 bytes in 169ms
12-20 20:30:38.333: INFO/ActivityManager(58): Starting activity: Intent { cmp=game.main/game.mainmenu.Highscores }
12-20 20:30:38.533: DEBUG/AndroidRuntime(362): Shutting down VM
12-20 20:30:38.533: WARN/dalvikvm(362): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-20 20:30:38.553: ERROR/AndroidRuntime(362): FATAL EXCEPTION: main
12-20 20:30:38.553: ERROR/AndroidRuntime(362): java.lang.RuntimeException: Unable to start activity ComponentInfo{game.main/game.mainmenu.Highscores}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.os.Looper.loop(Looper.java:123)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.ActivityThread.main(ActivityThread.java:4627)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at java.lang.reflect.Method.invokeNative(Native Method)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at java.lang.reflect.Method.invoke(Method.java:521)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at dalvik.system.NativeStart.main(Native Method)
12-20 20:30:38.553: ERROR/AndroidRuntime(362): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.ListActivity.onContentChanged(ListActivity.java:245)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.Activity.setContentView(Activity.java:1647)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at game.mainmenu.Highscores.onCreate(Highscores.java:15)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
12-20 20:30:38.553: ERROR/AndroidRuntime(362):     ... 11 more
12-20 20:30:38.563: WARN/ActivityManager(58):   Force finishing activity game.main/game.mainmenu.Highscores
12-20 20:30:38.563: WARN/ActivityManager(58):   Force finishing activity game.main/game.mainmenu.MainMenuActivity
12-20 20:30:39.091: WARN/ActivityManager(58): Activity pause timeout for HistoryRecord{45028190 game.main/game.mainmenu.Highscores}
12-20 20:30:41.193: INFO/Process(362): Sending signal. PID: 362 SIG: 9
12-20 20:30:41.293: INFO/ActivityManager(58): Process game.main (pid 362) has died.
12-20 20:30:41.293: INFO/WindowManager(58): WIN DEATH: Window{450b3e40 game.main/game.mainmenu.MainMenuActivity paused=true}
12-20 20:30:45.032: DEBUG/dalvikvm(258): GC_EXPLICIT freed 31 objects / 1448 bytes in 128ms
12-20 20:30:49.573: WARN/ActivityManager(58): Activity destroy timeout for HistoryRecord{44f4d640 game.main/game.mainmenu.MainMenuActivity}
12-20 20:30:49.642: WARN/ActivityManager(58): Activity destroy timeout for HistoryRecord{45028190 game.main/game.mainmenu.Highscores}

Highscores.xml

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/widget32"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:stretchColumns="1">

    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
    <TableRow>
        <TextView android:layout_column="1" android:text="Johonunu"
            android:padding="3dip" />
        <TextView android:text="10000" android:gravity="right"
            android:padding="3dip" />
    </TableRow>
</TableLayout>

Highscores activity

package game.mainmenu;

import game.main.R;
import android.app.Activity;
import android.app.ListActivity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

public class Highscores extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.highscores);      


    }
}

MainMenu xml

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget32"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bckgr2"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TableLayout
android:id="@+id/widget28"
android:layout_width="295px"
android:layout_height="600px"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
>
<Button
android:id="@+id/StartGame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/startgame_button"
>
</Button>
<TextView
android:id="@+id/widget34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</TextView>
<Button
android:id="@+id/Help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/help_button" 
>
</Button>
<TextView
android:id="@+id/widget35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</TextView>
<Button
android:id="@+id/Highscores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/highscores_button" 
>
</Button>
<TextView
android:id="@+id/widget36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</TextView>
<Button android:id="@+id/Quit" android:background="@drawable/quit_button" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button>

</TableLayout>
</RelativeLayout>

Main menu activity

package game.mainmenu;

import game.main.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class MainMenuActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        final Activity t = this;
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN );
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.main);

        Button StartGameButton = (Button)findViewById(R.id.StartGame);//кнопка начала игры
        StartGameButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent StartGameIntent = new Intent(MainMenuActivity.this, StartGame.class);
                startActivity(StartGameIntent);
            }
        });

        Button HelpButton = (Button)findViewById(R.id.Help);//кнопка help
        HelpButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent HelpIntent = new Intent(MainMenuActivity.this, Help.class);
                startActivity(HelpIntent);
            }
        });

        Button OptionsButton = (Button)findViewById(R.id.Highscores);//кнопка 
        OptionsButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent OptionsIntent = new Intent(MainMenuActivity.this, Highscores.class);
                startActivity(OptionsIntent);
            }
        });

        Button QuitButton = (Button)findViewById(R.id.Quit);//кнопка 
        QuitButton.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                t.finish();//завершаем работу приложения
            }
        });


    }

}

It was working when in highscores xml was this

<?xml version="1.0" encoding="utf-8" ?> 
- <RelativeLayout android:id="@+id/widget32" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
  <TextView android:text="This is where you would show any options your game has" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content" /> 
  </RelativeLayout>

but when i change it back - error dosen't disapperaed/ What happend? How can i solve this problem?

3 Answers 3

4

You must have changed something else. Your Highscores activity class is extending ListActivity, which requires a ListView to be present in your layout xml with the id android.R.id.list, e.g.

     <ListView  
     android:id="@android:id/list"
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     />
Sign up to request clarification or add additional context in comments.

Comments

2

It shouldn't have worked either way. Your HighScores Activity shouldn't extend ListActivity if you aren't using a ListView in your layout. Instead, extend from Activity.

Comments

0

Your error says {game.main/game.mainmenu.Highscores}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'. Your Highscores class is a listactivity, then you have to add a list. Try changing the class to an Activity.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.