Changing Intent Problem

Put your problem here if it does not fit any of the other categories.

Changing Intent Problem

Postby Ignant » Wed Sep 08, 2010 9:06 pm

Hello,

I am trying to change between intents using a separate class that I created so I do not have to code it for each Intent. The button I am using to switch between events appears fine but when I click it the app crashes.

Here is the class I created for the purpose:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.app.Activity;
  2. import android.content.Context;
  3. import android.content.Intent;
  4. import android.view.View;
  5. import android.view.ViewGroup.LayoutParams;
  6. import android.widget.Button;
  7.  
  8. public class IntentButton extends Activity{
  9.         public Button createButton(final Context ct, Class c, String text){
  10.                         Button intentButton = new Button(ct);
  11.                         ...
  12.                         intentButton.setOnClickListener(new View.OnClickListener() {
  13.                                 @Override
  14.                                 public void onClick(View view) {
  15.                                         Intent i = new Intent(ct, c);
  16.                                         startActivity(i);
  17.                                 }
  18.                         });
  19.                 return intentButton;
  20.         }
  21. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4



and here is the code in the Intents to create the button:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. IntentButton btn = new IntentButton();
  2.         panel.addView(btn.createButton(IntentA.this, IntentDemo.class, "Screen 1"));
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Any ideas what I need to do to fix this?
Ignant
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sat Aug 28, 2010 10:20 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 14 guests