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

Apps Eclipse onClick buttons don't work properly

Discussion in 'Android Development' started by adamj1910, Aug 7, 2013.

  1. adamj1910

    adamj1910 Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    2
    Joined:
    Jan 31, 2013

    Jan 31, 2013
    2
    0
    5
    Hi All!

    I'm having a small problem with some onClick events, it's probably my .java file, the problem is once i test the app, virtual or real device, there are 2 buttons, 1 for Facebook(button1) and 1 for Twitter(button2), the Twitter one won't work until the Facebook one has been "clicked" and then you have to press back to then "click" the Twitter button.

    I'm new to this so knowing my luck the java file is stating that "button2 will only work once button1 has been clicked"

    If anyone would like me to post the file please let me know.

    Thanks!!!
     

    Advertisement

  2. Petrah

    Petrah Psychotic Female
    Rank:
    None
    Points:
    333
    Posts:
    4,085
    Joined:
    Jun 13, 2011

    Jun 13, 2011
    4,085
    1,467
    333
    Female
    Annoying my X-Husband
    Hanover Park, IL
    Thread moved to a more appropriate forum. :)
     
  3. out of ideas

    out of ideas Android Enthusiast
    Rank:
    None
    Points:
    93
    Posts:
    640
    Joined:
    May 19, 2012

    May 19, 2012
    640
    145
    93
    if you have code problems, always post your code

    in [ code] tags please
     
  4. steve

    steve Developer
    Administrator
    Rank:
    None
    Points:
    573
    Posts:
    1,086
    Joined:
    Apr 19, 2011

    Apr 19, 2011
    1,086
    1,180
    573
    Male
    Android Developer
    York, PA
    Agreed. Please post your code and we will help.

    Examples of onClick are like this:

    Code (Text):
    1.  
    2. Button btnClick = (Button) findViewById(R.id.button);
    3. btnClick.setOnClickListener(new View.OnClickListener() {
    4.     @Override
    5.     public void onClick(View v) {
    6.         myMethod(v);
    7.     }
    8. });
    9.  
    or in your xml file you can call the method like so:

    Code (Text):
    1.  
    2. <Button android:id="@+id/button"
    3.     android:layout_width="wrap_content"
    4.     android:layout_height="wrap_content"
    5.     android:text="Click Example"
    6.     android:onClick="myMethod" />
    7.  
    The xml example you need to have your method passing a view.

    Hope this helps someone.. and please post your code if you still have issues.
     

Share This Page

Loading...