Hey guys i'm new in Android's dev and for a project, I have to implement a listener for a button. But unfortunately, he can't detect the button I think. Here is the java code :
public class Touch extends AppCompatActivity implements OnTouchListener,OnClickListener {
private button boutonCompteur = null;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.id.Compteur);
boutonCompteur = (button) findViewById(R.id.Compteur);
boutonCompteur.setOnTouchListener(this);
boutonCompteur.setOnClickListener(this);
}
@Override
public boolean onTouch(View v, MotionEvent event)
{
return true;
} }
and here is the XML :
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="appuyez ici pour compter votre nombre de touch"
android:id="@+id/Compteur"
android:height="130dp"
android:textColor="#1818e3"
android:textColorHighlight="#cd5555"
android:textSize="22dp"
android:textStyle="italic"
android:layout_marginTop="150dp"
android:layout_alignParentStart="true" />
Thanks for your answers :)
