1. Download our Official Android App: Forums for Android!

Apps Buttons problems...

Discussion in 'Android Development' started by sunde, Aug 13, 2012.

  1. sunde

    sunde Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Aug 13, 2012

    Aug 13, 2012
    6
    0
    5
    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 Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    Moved to Dev 101. =)
     
  3. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    What does your onClick listener(s) for your buttons look like?
     
  4. sunde

    sunde Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Aug 13, 2012

    Aug 13, 2012
    6
    0
    5
    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 Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    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 Member
    Rank:
    None
    Points:
    38
    Posts:
    35
    Joined:
    Aug 8, 2012

    Aug 8, 2012
    35
    12
    38
    Rookie Indie Developer
    Texas
    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 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Aug 13, 2012

    Aug 13, 2012
    6
    0
    5
    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 Member
    Rank:
    None
    Points:
    38
    Posts:
    35
    Joined:
    Aug 8, 2012

    Aug 8, 2012
    35
    12
    38
    Rookie Indie Developer
    Texas
    Are the other activities registered in your androidmanifest.xml file?
     
  9. chakdev

    chakdev Newbie
    Rank:
    None
    Points:
    16
    Posts:
    16
    Joined:
    Aug 21, 2012

    Aug 21, 2012
    16
    1
    16
    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...