0

私はこのようなボタンを持っています:

<Button
  android:id="@+id/logout_button"        
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:text="Log out"
/> 

そして私にはこのようなリスナーがいます:

        Button logout = (Button)findViewById(R.id.logout_button);           

        logout.setOnClickListener(new Button.OnClickListener() 
        {  
            public void onClick(View v) 
            {
                Toast.makeText(getApplicationContext(), "Logging out. Please wait...", Toast.LENGTH_LONG).show();   

                sendEmail("Logout Chosen", "From home page, user clicked on logout" );      

                Intent myIntent = new Intent(ProblemioActivity.this, LogoutActivity.class);
                ProblemioActivity.this.startActivity(myIntent);
            }
        });         

これにあまり多くの変更を加えたのを覚えていませんが、ボタンが突然クリックに反応しなくなりました。面白いことに、同じページに他のボタンはすべてまだうまく機能しています。

なぜこれが起こるのか考えてみませんか?

ありがとう!

4

1 に答える 1

1

1)コードを再構築してみて、それが機能するかどうかを確認します。ECLIPSE:プロジェクト>クリーン>プロジェクト

2)また、他のボタンのIDを確認し、誤って同じ名前を付けていないことを確認します(IDが「logout_button」のボタンは1つだけにする必要があります)。

于 2012-04-04T11:31:36.877 に答える