local class and new activity in simulator


Last Updated:

  1. bigautosurfer

    bigautosurfer New Member This Topic's Starter

    Joined:
    Feb 14, 2009
    Messages:
    1
    Likes Received:
    0
    I am having trouble running my application as every time i try to run
    it the simulator gives me a an error. I looked through the
    Documentation but I couldn't find anything on user created classes.
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.EditText;

    public class survey extends Activity {
    private EditText questions;
    private EditText answers;
    private Button next;
    private Button done;
    private OnClickListener nextListener;
    private OnClickListener doneListener;
    private Forms list = new Forms();
    int t;

    /** Called when the activity is first created. */
    @Override

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.questions_app);
    questions = (EditText) findViewById(R.id.questions);
    answers = (EditText) findViewById(R.id.answers);
    next = (Button) findViewById(R.id.next);
    done = (Button) findViewById(R.id.done);
    t = 0;
    nextListener = new OnClickListener(){
    public void onClick(View v) {
    // TODO Auto-generated method stub
    String qtemp = questions.getText().toString();
    list.setA(t, qtemp);
    String atemp = answers.getText().toString();
    String[] answer = atemp.split("|");
    list.setQ(t, answer);
    t++;
    questions.setText("");
    answers.setText("");
    }

    };
    doneListener = new OnClickListener(){

    public void onClick(View v) {
    // TODO Auto-generated method stub
    //starting temp and finishing the
    current activity
    Q_end temp = new Q_end();
    temp.startActivity(null);
    finish();
    }
    };
    done.setOnClickListener(doneListener);
    }

    }


    I figure out that the instance of the Forms class is the cause but I'm
    not sure why. Forms is a class that I created in the same package.
    Also when I try to start the activity Q-end and finish the current
    activity, it also gives me a error. Can some1 tell me what i'm doing
    wrong?
     

    Advertisement
  2. moshstef

    moshstef Member

    Joined:
    Dec 20, 2008
    Messages:
    5
    Likes Received:
    0
    Are we allowed to see the error you are getting?

    Also this may be a wron observation but I see that you are doing list.setA() to set the question and list.setQ to set the answers. Shouldn't it be the other way around?
     

Share This Page

Loading...