我在Activity中有这两个按钮。 backBtn
工作正常,但点击reg_country
按钮后没有任何反应。知道发生了什么事吗?
[编辑]使用某些日志编辑,当我触摸按钮时,onClick
只是不执行。
08-10 09:33:08.608: D/dalvikvm(806): GC_EXTERNAL_ALLOC freed 365 objects / 24360 bytes in 58ms
08-10 09:33:11.608: E/RegisterActivity(806): Activity started
08-10 09:33:14.317: E/RegisterActivity(806): onClick (backBtn)
08-10 09:33:16.268: E/RegisterActivity(806): Activity started
活动代码的一部分
Log.e("RegisterActivity", "Activity started");
backBtn = (Button) findViewById(R.id.backBtn);
backBtn.setText("Cancelar");
backBtn.setVisibility(View.VISIBLE);
backBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("RegisterActivity", "onClick (backBtn)");
finish();
}
});
reg_country = (Button) findViewById(R.id.reg_country);
reg_country.setText("reg_country");
reg_country.setClickable(true);
reg_country.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.e("RegisterActivity", "onClick (reg_country)");
finish();
}
});
可能因为reg_country
留在TableLayout
内? backBtn来自包含的actionbar_layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<include
android:id="@+id/include1"
layout="@layout/actionbar_layout" />
<!-- Registration Form -->
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="20dip"
android:background="@drawable/balao_formulario_cadastrar"
android:clickable="true"
android:gravity="center"
android:isScrollContainer="true"
android:orientation="vertical"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="50dip"
android:stretchColumns="1" >
<EditText
android:id="@+id/reg_fullname"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_marginBottom="20dip"
android:layout_marginTop="5dip"
android:background="@drawable/stroke"
android:hint="Nome Completo"
android:imeOptions="actionNext"
android:inputType="textPersonName"
android:singleLine="true" />
<EditText
android:id="@+id/reg_email"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_marginBottom="20dip"
android:layout_marginTop="5dip"
android:background="@drawable/stroke"
android:hint="E-mail"
android:inputType="textEmailAddress"
android:singleLine="true" />
<EditText
android:id="@+id/reg_password"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_marginBottom="20dip"
android:layout_marginTop="5dip"
android:background="@drawable/stroke"
android:hint="Senha"
android:password="true"
android:singleLine="true" />
<Button
android:id="@+id/reg_country"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_marginBottom="25dip"
android:clickable="true"
android:gravity="left|center_vertical"
android:text="Selecione um País"
android:textSize="15dip" />
<!-- Terms of Use TextView -->
<TextView
android:id="@+id/reg_terms_link"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/termos"
android:textColor="#3D3D3D"
android:textSize="10dip" />
</TableLayout>
<Button
android:id="@+id/registerBtn"
android:layout_width="fill_parent"
android:layout_height="35dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_marginTop="20dip"
android:background="@drawable/button_cadastrar"
android:text="Cadastrar"
android:textColor="#3D3D3D"
android:textSize="15dip" />
<!-- Registration Form Ends -->
</LinearLayout>