0
简单的问题,但我卡住了:-(我能够完全按照教程做这个工作,但当我试图重新创建它时,我的按钮将无法工作,没有错误。只是,当我按一下按钮没有任何反应。任何想法?OnClickListener - Android Eclipse
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>
谢谢!
您在OnCreate方法中调用了listener()吗? – Ahmad
你确定'resetCounter(v);'方法工作正常吗?这种方法发生了什么? –
愚蠢的我。我从来没有叫过监听器()。感谢ahmad!请回答,所以我可以给你复选标记 – Evorlor