我正在尝试将按钮添加到我的活动中。我可以看到按钮,但按下它时没有任何反应。代码如下。
谢谢,那鸿
清单.xml:
<Button android:layout_gravity="bottom" android:layout_weight="1" android:text="Next" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/w_button_next"></Button>
爪哇:
private Button b3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wizard);
b3 = (Button) findViewById(R.id.w_button_next);
b3.setOnClickListener(new NextClicked());
}
class NextClicked implements Button.OnClickListener {
public void onClick(View v) {
Context context = v.getContext();//getApplicationContext();
CharSequence text = "On Click";
int duration = Toast.LENGTH_LONG;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
GotoNextState();
}
}