android pourquoi ce bouton n'est pas cliquable
Je ne sais pas pourquoi les deux derniers boutons n'est pas cliquable, j'ai utilisé le fond (que j'ai mis ) beaucoup de temps et il fonctionne avec d'autres mises en page, je suis sûr que le mal est quelque chose comme foucable ou cliquable mais je ne sais pas où exactement .
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="20dip"
android:layout_weight="1" >
<Button
android:id="@+id/b_orderMeal_selectRestaurant"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="30dip"
android:text="@string/b_selectRestaurant" />
<ImageView
android:id="@+id/iv_orderMeal_isSelectRestaurant"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:contentDescription="@string/iv_isSelected"
android:src="@drawable/x" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="20dip"
android:layout_weight="1" >
<Button
android:id="@+id/b_orderMeal_selectMealItems"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="30dip"
android:text="@string/b_select_MealItems" />
<ImageView
android:id="@+id/iv_orderMeal_isSelectMealItems"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:contentDescription="@string/iv_isSelected"
android:src="@drawable/x" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="20dip"
android:layout_weight="1" >
<Button
android:id="@+id/b_orderMeal_selectPayMethod"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="30dip"
android:text="@string/b_selectPayMethod" />
<ImageView
android:id="@+id/iv_orderMeal_isSelectPayMethod"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:contentDescription="@string/iv_isSelected"
android:src="@drawable/x" />
</RelativeLayout>
<Button
android:id="@+id/b_orderMeal_checkBasket"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="40dip"
android:layout_marginTop="20dip"
android:layout_weight="1"
android:text="@string/b_check_basket" />
<TextView
android:id="@+id/tv_orderMeal_errorMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="30dip"
android:layout_weight="1"
android:text="@string/tv_orderMeal_errorMessage"
android:textColor="#FF0000"
android:textSize="20dip"
android:textStyle="bold"
android:typeface="sans" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/bg_selector"
android:orientation="horizontal" >
<Button
android:id="@+id/b_orderMeal_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="4dip"
android:layout_weight="1"
android:background="@drawable/button_bg"
android:text="@string/b_send"
android:focusable="true"
android:clickable="true"
android:textColor="#FFFFFF" />
<Button
android:id="@+id/b_orderMeal_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dip"
android:layout_weight="1"
android:background="@drawable/button_bg"
android:text="@string/b_cancel"
android:clickable="true"
android:textColor="#FFFFFF" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
Je parle les deux derniers boutons
java
b_send = (Button) findViewById(R.id.b_orderMeal_send);
b_send.setOnClickListener(this);
b_cancel = (Button) findViewById(R.id.b_orderMeal_cancel);
b_cancel.setOnClickListener(this);
sur cliquez
@Override
public void onClick(View v) {
case R.id.b_orderMeal_cancel:
Toast.makeText(this, "roma", Toast.LENGTH_LONG);
break;
}
remarque
le toast ne semble pas
Et comment savez-vous qu'ils ne sont pas cliquables? où est votre code java?
Espérons que vous avez ajouté le code pour OnClickListener pour les deux derniers boutons. Veuillez vérifier oyour code et confirmer
je l'ai ajouté.........
Vous devez ajouter un peu de journaux ou quelque chose dans le onClick, sinon comment le savoir est-il cliquable ou pas?
pls envoyer l'ensemble de la mise en œuvre de onClick. de quoi êtes-vous à l'aide dans l'instruction switch?
Espérons que vous avez ajouté le code pour OnClickListener pour les deux derniers boutons. Veuillez vérifier oyour code et confirmer
je l'ai ajouté.........
Vous devez ajouter un peu de journaux ou quelque chose dans le onClick, sinon comment le savoir est-il cliquable ou pas?
pls envoyer l'ensemble de la mise en œuvre de onClick. de quoi êtes-vous à l'aide dans l'instruction switch?
OriginalL'auteur user2059935 | 2013-02-12
Vous devez vous connecter pour publier un commentaire.
Je pense que votre
XML
design est OK dans toutes les formes, alors le problème est probablement dansJava
. Très probablement, vous avez oublié de vous inscrireOnClickListener
pour votreButton(s)
.Ou vous pouvez utiliser
OnClickListener
interface, puismon activité est implémente onclicklistenr
alors, où est le problème?
Je ne sais pas où est le problème , je suis confus au sujet de ce problème
vérifier mon montage, le toast ne s'affiche pas, pourquoi pelase?
OriginalL'auteur Simon Dorociak
Remplacer votre
onClick()
méthode dessous et laissez-nous savoir au sujet de logcat.il semble que vous essayez de montrer
toast
mais manquant.show()
méthode pour montrer le toast.Essayez de code ci-dessous et laissez-nous savoir
toujours pas cliquable
Vérifiez de nouveau, vous êtes absent .show() sur des toasts.makeText méthode, et de mettre en œuvre la Vue.onClickListener interface dans votre activité.
Et vous pouvez utiliser d'interrupteur ou de l'égalité, le résultat va de même. Donc pas de soucis.
Mais je ne recommande pas d'utiliser la méthode equals pour atteindre cet objectif. Son sale et il y a mieux et plus propre solution.
OriginalL'auteur AAnkit
ensemble cliquable = true dans le fichier xml pour votre bouton et essayer dans votre code.
OriginalL'auteur khubaib