我的PopUpMenu没有做任何事情

时间:2013-04-22 22:52:07

标签: java android android-intent

我正在处理Android Developer Tutorial,当我尝试打开某个活动时,它什么也没做。

这是我的Main.java

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;
import android.widget.Toast;

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class Main extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main); 
                Toast.makeText(getApplicationContext(), "Probandooo", Toast.LENGTH_LONG).show();
        }

        public void showPopup(View v) {
            PopupMenu popup = new PopupMenu(this, v);
            MenuInflater inflater = popup.getMenuInflater();
            inflater.inflate(R.menu.main, popup.getMenu());
            popup.show();
        }

        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
                case R.id.responder:
                        Intent i = new Intent (Main.this, Responder.class);
                        startActivity(i);
                    return true;
                case R.id.reenviar:
                        Toast.makeText(getApplicationContext(), "Reenviando...", Toast.LENGTH_SHORT).show();
                    return true;
                default:
                    return false;
            }
        }
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
                // Inflate the menu; this adds items to the action bar if it is present.
                getMenuInflater().inflate(R.menu.main, menu);
                return true;
        }

}

我已经在我的清单上声明了,我不知道是什么

0 个答案:

没有答案