@OnClick不工作实施ButterKnife图书馆 [英] @OnClick is not working in implementation of ButterKnife Library
本文介绍了@OnClick不工作实施ButterKnife图书馆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
@OnClick
不工作实施ButterKnife库
@OnClick
is not working in implementation of ButterKnife Library
当我点击按钮
,什么也没发生。
When I click on the Button
, nothing is happening.
这是我的全部code:
This is my full code:
public class MainActivity extends ActionBarActivity {
@InjectView(R.id.edit_user)
EditText username;
@InjectView(R.id.edit_pass)
EditText password;
@OnClick(R.id.btn)
void submit() {
// TODO call server...
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
// TODO Use "injected" views...
}
}
这是我的xml:
<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" >
<EditText
android:id="@+id/edit_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="user" />
<EditText
android:id="@+id/edit_pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="user" />
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
感谢
推荐答案
诚如Butterknife文档,如果你使用的是Eclipse,你需要的configure 的注释将被处理之前,IDE
As mentioned in the Butterknife docs, If you are using Eclipse, you will need to configure the IDE before the annotations will be processed
这篇关于@OnClick不工作实施ButterKnife图书馆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文