1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

Buttons problems...


Last Updated:

  1. sunde

    sunde Member This Topic's Starter

    Joined:
    Aug 13, 2012
    Messages:
    6
    Likes Received:
    0
    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

    Joined:
    Jul 13, 2010
    Messages:
    1,934
    Likes Received:
    458
    Moved to Dev 101. =)
     
  3. jonbonazza

    jonbonazza Well-Known Member

    Joined:
    Jul 13, 2010
    Messages:
    1,934
    Likes Received:
    458
    What does your onClick listener(s) for your buttons look like?
     
  4. sunde

    sunde Member This Topic's Starter

    Joined:
    Aug 13, 2012
    Messages:
    6
    Likes Received:
    0
    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

    Joined:
    Jul 13, 2010
    Messages:
    1,934
    Likes Received:
    458
    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

    Joined:
    Aug 8, 2012
    Messages:
    35
    Likes Received:
    12
    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 This Topic's Starter

    Joined:
    Aug 13, 2012
    Messages:
    6
    Likes Received:
    0
    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

    Joined:
    Aug 8, 2012
    Messages:
    35
    Likes Received:
    12
    Are the other activities registered in your androidmanifest.xml file?
     
  9. chakdev

    chakdev Member

    Joined:
    Aug 21, 2012
    Messages:
    16
    Likes Received:
    1
    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?
     

Share This Page

Loading...