My intent to go to another android page isn't activating when i click the button.
My java code
public class CharSheets extends Activity implements OnClickListener{
Button Descrip, Atributes, Weapons, Skills, ACItems, Gear,
Feats, SpecialAbilities, Spells;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.charsheets);
setids();
}
private void setids() {
// TODO Auto-generated method stub
Descrip = (Button)findViewById(R.id.bCharDescrip);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId()) {
case R.id.bCharDescrip:
Intent i = new Intent(CharSheets.this, CharDescrip.class);
startActivity(i);
break;
case R.id.bCharAtributes:
Intent i1 = new Intent(CharSheets.this, CharAtributes.class);
startActivity(i1);
break;
}
}
}
The XML mainfest
<activity
android:name=".CharAtributes"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.CHARSATRIBUTES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".CharDescrip"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.CHARDESCRIP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I'm not sure what is causing the issue, but I have tried other solutions none of them have worked. The way I'm doing it now I have used before and it has worked just fine.
You haven't set an onClickListener() for you Button
private void setids() {
// TODO Auto-generated method stub
Descrip = (Button)findViewById(R.id.bCharDescrip);
Descrip.setOnClickListener(this); // add this line
}
Now add your other Buttons here and use the setOnClickListener() for each in the same way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With