简单的问题,但我被卡住了:-(我完全按照教程进行操作时能够完成这项工作,但是当我尝试重新创建它时,我的按钮不起作用。没有错误。只是当我没有任何反应时点击按钮。有什么想法吗?
public void listener() {
Button btnReset = (Button) findViewById(R.id.bl);
btnReset.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
resetCounter(v);
count = 0;
}
});
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Counter" >
<TextView
android:id="@+id/tvCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<Button
android:id="@+id/bl"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="@string/btnReset"
android:textSize="20sp" />
</RelativeLayout>
谢谢!