Buttons problems...


  1. sunde

    sunde Member

    Hello

    i have made a own app but

    when i press on the buttons it dont go to the activity but

    if i press the buttons in one order it goes perfectly what is wrong?

    i wanna press with button i want and not in one spec order to work

    can someone help me with an answer how i should write so it could work with any button directly.

    Cincearly

    sunde

    Advertisement
    :
  2. jonbonazza

    jonbonazza Well-Known Member

    Moved to Dev 101. =)
  3. jonbonazza

    jonbonazza Well-Known Member

    What does your onClick listener(s) for your buttons look like?
  4. sunde

    sunde Member

    Button bomoss = (Button) findViewById (R.id.omoss);
    bomoss.setOnClickListener(new View.OnClickListener() {

    this you mean?

    or


    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    startActivity(new Intent("xxx.xx.xxxxxx.xxxxxx.OMOSS"));
  5. jonbonazza

    jonbonazza Well-Known Member

    show me the onClick method (the second thing in your post) for all of your buttons. You must not be handling some of them correctly.
  6. SmugMug

    SmugMug Active Member

    If you're changing your buttons' onClickListeners at runtime using setOnClickListener, make sure you generate your intent and start your activity intent for each onClickListener for each button you want to have enabled.

    If you are changing the state/action of other buttons with each button press, you may have to call nested onClickListeners as you set up what the different buttons do under each condition...but it gives me a headache just thinking about that.
  7. sunde

    sunde Member

    Button bomoss = (Button) findViewById (R.id.omoss);
    bomoss.setVisibility(View.VISIBLE);
    bomoss.setBackgroundColor(Color.TRANSPARENT);
    bomoss.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    startActivity(new Intent("x.x.x.OMOSS"));

    Button bhittaoss = (Button) findViewById (R.id.hittaoss);
    bhittaoss.setVisibility(View.VISIBLE);
    bhittaoss.setBackgroundColor(Color.TRANSPARENT);
    bhittaoss.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    startActivity(new Intent("x.x.x.HITTAOSS"));

    Button bkontaktaoss = (Button) findViewById (R.id.kontaktaoss);
    bkontaktaoss.setVisibility(View.VISIBLE);
    bkontaktaoss.setBackgroundColor(Color.TRANSPARENT);
    bkontaktaoss.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub
    startActivity(new Intent("x.x.x.KONTAKTAOSS"));
  8. SmugMug

    SmugMug Active Member

    Are the other activities registered in your androidmanifest.xml file?
  9. chakdev

    chakdev Member

    You have three buttons in the code that you pasted. Clicking on each of them should launch an activity.

    By special order do you mean something like you need to press button one then button two, then button three for your app to launch an activity?
Loading...

Share This Page