I think that
Button bTutorial1 = (Button) findViewById(R.layout.tutorial1);
bTutorial1.setOnClickListener(new View.OnClickListener() {
is equal to “Null”.
( I read it somewhere but did not see a fix to it)
If that isn’t the problem plz I don’t know..
Thx for any help I can get.
Sincerely, Robin
activity_main Code:
<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=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/gotoKanal2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/gotoKanal3"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="@string/tv_2" />
<Button
android:id="@+id/gotoKanal3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/tutorial1"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="@string/tv_3" />
<Button
android:id="@+id/tutorial1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/tutorial2"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="TUTORIALONE" />
<Button
android:id="@+id/tutorial2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/gotoKanal6"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="-||- 2" />
<Button
android:id="@+id/gotoKanal6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="@string/tv_6" />
<Button
android:id="@+id/gotoKanal1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/gotoKanal2"
android:layout_alignParentLeft="true"
android:layout_marginBottom="14dp"
android:text="@string/tv_1" />
</RelativeLayout>
mainifest Code: Ignore all the .tv
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Robin.Robin"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
<activity
android:name="com.Robin.Robin.MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter >
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name="myMenu"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter >
<action android:name="com.Robin.Robin.CLEARSCREEN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".tutorialOne"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter >
<action android:name="com.Robin.Robin.TUTORIALONE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".tv2"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter >
<action android:name="com.Robin.Robin.tv2"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".tv3"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter >
<action android:name="com.Robin.Robin.tv3"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name="com.Robin.Robin.tv4"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter >
<action android:name="com.Robin.Robin.tv4"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".tv5"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter >
<action android:name="com.Robin.Robin.tv5"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".tv6"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter >
<action android:name="com.Robin.Robin.tv6"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
splash Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/default_320x480" />
</LinearLayout>
myMeny.java Code:
package com.Robin.Robin;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class myMenu extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bTutorial1 = (Button) findViewById(R.layout.tutorial1);
bTutorial1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.Robin.Robin.TUTORIALONE"));
}
});
Button bgotoKanal4 = (Button) findViewById(R.id.gotoKanal4);
bgotoKanal4.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity (new Intent ("package com.Robin.Robin.tv4"));
Button bgotoKanal2 = (Button) findViewById(R.id.gotoKanal2);
bgotoKanal2.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity (new Intent ("package com.Robin.Robin.tv2"));
Button bgotoKanal3 = (Button) findViewById(R.id.gotoKanal3);
bgotoKanal3.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity (new Intent ("package com.Robin.Robin.tv3"));
Button bgotoKanal1 = (Button) findViewById(R.id.gotoKanal1);
bgotoKanal1.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity (new Intent ("package com.Robin.Robin.tv1"));
Button bgotoKanal5 = (Button) findViewById(R.id.gotoKanal5);
bgotoKanal5.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
TODO Auto-generated method stub
startActivity (new Intent ("package com.Robin.Robin.tv5"));
Button bgotoKanal6 = (Button) findViewById(R.id.gotoKanal6);
bgotoKanal6.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity (new Intent ("package com.Robin.Robin.tv6"));
}
} );
}
} );
}
} );
}
} );
}
} );
}
} );
}
}
MainActivity code:
package com.Robin.Robin;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
MediaPlayer mpSplash;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
mpSplash = MediaPlayer.create(this, R.raw.javaintro);
mpSplash.start();
Thread logoTimer = new Thread(){
public void run(){
try{
int logoTimer = 0;
while(logoTimer < 5000){
sleep(100);
logoTimer = logoTimer + 100;
}
startActivity(new Intent("com.Robin.Robin.CLEARSCREEN"));
}
catch (InterruptedException e){
e.printStackTrace();
}
finally{
finish();
}
}
};
logoTimer.start();
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
mpSplash.release();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
mpSplash.pause();
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
mpSplash.start();
}
@Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
}
@Override
protected void onStop() {
// TODO Auto-generated method stub
super.onStop();
}
}
should be
Because your Button in xml is defined as
Which will be defined in
R.id, therefore, you retrieve it asR.id.tutorial1In addition to the problem, did you forget to close your OnClickListener?