[英]How to open a new activity when a button is clicked?
我正在制作一個android應用程序,我想要它,以便當某人單擊主菜單活動中的按鈕時,他們將進入相應的活動。 目前,我的代碼是:
菜單xml中的按鈕:
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Dwight Quotes" android:id="@+id/DwightButton" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:onClick="openNewActivity" android:background="#EAD383" android:enabled="false" />
菜單java:
public void openNewActivity(View view) { // Do something in response to button Intent intent = new Intent(this, Dwight.class); startActivity(intent);
當我單擊按鈕時,什么也沒有發生。 有人可以解釋我需要做什么嗎?
從您的代碼中刪除android:enabled =“ false” 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.