我有一個相對佈局一個Android應用程序,我已經把一個按鈕控件這樣Android的按鈕單擊事件是不是爲我工作
<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="wrap_content" >
<Button
android:id="@+id/btnCalc"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="708dp"
android:layout_marginLeft="50dp"
android:text="@string/btncalc" />
</RelativeLayout>
和測試的事件中,我已放置在此單擊事件敬酒這樣
btncalcu=(Button)findViewById(R.id.btnCalc);
btncalcu.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v)
{
Toast.makeText(getBaseContext(), "a", Toast.LENGTH_LONG).show();
//calc();
}
});
問題按鈕是,當我運行該應用程序有沒有錯誤或任何異常,但也沒什麼顯示的Toast
有。任何能猜到可能b是出的問題.Plz幫助!
你可以在這裏添加完整的活動類代碼嗎? –
僅使用此代替getBaseContext() – Unknown