1
How do I make my layout clickable?
For example, I divide the screen into 2 layouts, 1 green with 50% of the screen and the other red with the other 50%. How to make them clickable?
1
How do I make my layout clickable?
For example, I divide the screen into 2 layouts, 1 green with 50% of the screen and the other red with the other 50%. How to make them clickable?
5
Set your layouts' XML to tag:
android:clickable=“true”
After that just treat the click as you treat the click on any other view, as in a button, for example.
2
LinearLayout meuComponente = (LinearLayout) findViewById (R.id.meu_componente);
meuComponente.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(this, "hello", Toast.LENGTH_LONG).show();
//Insira qualquer comportamento aqui. (:
}
});
Don’t forget to set the attribute of your LinearLayout
:
android:clickable="true"
If you want the elements within the LinearLayout
are not clickable, use: android:clickable="false"
for all elements.
Browser other questions tagged android android-layout
You are not signed in. Login or sign up in order to post.
Thank you!! helped mt
– Biellx