0

I have a problem I have created a simple list items and my item is Entertainment I have created the XML and Java file but after running into an emulator it doesn't work. I mean list items work, entertainment is here but clicking it won't make it to the next. Help

This is the main activity file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Main" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" >
    </ListView>

</RelativeLayout>

This is the Java file:

package com.firstapp;

import android.app.Activity;
import android.content.Intent;

import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.VideoView;

public class Entertainment extends Activity {

    MediaPlayer ourSong;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.entertainment);
        ourSong = MediaPlayer.create(this, R.id.videoView1);
        ourSong.start();
        Thread timer = new Thread() {
            public void run() {
                try {
                    sleep(5000);

                } catch (InterruptedException e) {
                    e.printStackTrace();

                } finally {
                    Intent openStartingpoint = new Intent(
                            "com.bucky.android.Menu");
                    startActivity(openStartingpoint);

                }
            }
        };

        timer.start();
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        ourSong.release();
        finish();

    }

}

And this is the manifest

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="16" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.firstapp.Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

   <activity
        android:name="com.firstapp.Entertainment"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.Main" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>

2
  • Where have you defined your Menu activity in AndroidMenifest ? Commented Mar 6, 2013 at 12:24
  • Which is your launcher activity ? Commented Mar 6, 2013 at 12:25

2 Answers 2

1

In the Manifest, the tag "category" in your main activity intent is wrong:

   <activity
        android:name="com.firstapp.Main"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

You have to declare LAUNCHER instead of DEFAULT. See if it works after this change.

Sign up to request clarification or add additional context in comments.

Comments

0

you have to override itemclick method of your listview for that

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
    int position = arg2;

    // click event handling
    textQuestionCount.setText("Question " + String.valueOf(position + 1) + " of " + arg0.getCount());

    }

and also implement the interface OnItemClickListener in your class.

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.