我是一個新手在android和試圖創建一個小應用程序。android測試應用程序..東西沒有工作
我的Java文件:
//creating object for imagebutton class
ImageButton mainButton = (ImageButton) findViewById(R.id.imageButtonone);
//creating onclick listener
mainButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//show message
Toast toast = Toast.makeText(SkeletonActivity.this, "Button Pressed", Toast.LENGTH_LONG);
toast.show();
}
});
XML:
<ImageButton android:id="@+id/imageButtonone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/dog8" />
其中的ImageButton的id = imageButtonone。
我無法打印「按下按鈕」。 請幫忙!
請在您聲明ImageButton的位置顯示您的xml部分。 – freshDroid
好詞新手..很高興認識新單詞。 –
@freshDroid –
Vimalnath