• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Eclipse onClick buttons don't work properly

adamj1910

Lurker
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!!!
 
Agreed. Please post your code and we will help.

Examples of onClick are like this:

Code:
Button btnClick = (Button) findViewById(R.id.button);
btnClick.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        myMethod(v);
    }
});

or in your xml file you can call the method like so:

Code:
<Button android:id="@+id/button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Click Example"
    android:onClick="myMethod" />

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.
 
Back
Top Bottom