I have a multi screen app that only the first button works. alll of the other buttons crash when they go to the next java file. In the manifest I have all of them listed but I have no idea why its crashing. any ideas? package com.mike.BrowserScreen; import android.app.Activity; import android.os.Bundle; import android.widget.; import android.view.; import android.content.Intent;
public class BrowserScreenActivity extends Activity {
/** Called when the activity is first created. */
Button flea=null;
Button bu1=null;
Button bu2=null;
Button bu3=null;
TextView tv1=null;
TextView tv2=null;
TextView tv3=null;
TextView tv4=null;
TextView tv5=null;
TextView tv6=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
flea=(Button)findViewById(R.id.flea);
bu1=(Button)findViewById(R.id.bu1);
bu2=(Button)findViewById(R.id.bu2);
bu3=(Button)findViewById(R.id.bu3);
tv1=(TextView)findViewById(R.id.tv1);
tv2=(TextView)findViewById(R.id.tv2);
tv3=(TextView)findViewById(R.id.tv3);
tv4=(TextView)findViewById(R.id.tv4);
tv5=(TextView)findViewById(R.id.tv5);
tv6=(TextView)findViewById(R.id.tv6);
flea.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent myIntent=new Intent(v.getContext(),SecondActivity.class);
startActivity(myIntent);
}
});
bu1.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent myIntent1=new Intent(v.getContext(),ThirdActivity.class);
startActivity(myIntent1);
}
});
bu2.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent myIntent2=new Intent(v.getContext(),FourthActivity.class);
startActivity(myIntent2);
}
});
bu3.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent myIntent3=new Intent(v.getContext(),FifthActivity.class);
startActivity(myIntent3);
}
});
}
}
Heres the manifest
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".BrowserScreenActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SecondActivity"></activity>
<activity android:name=".ThirdActivity"></activity>
<activity android:name=".ForthActivity"></activity>
<activity android:name=".FifthActivity"></activity>
</application>
</manifest>
i figured it out in the other java files i forgot to change it to the right xml file.I will have another question on launching a website from a textview or button
while starting new Activity..
Instead of
v.getContext()
useBrowserScreenActivity.this
orgetBaseContext()
like this