import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.widget.LinearLayout; import com.cnmobile.beibei.R; /** * @author 仿弹出popwindown菜单 */ public class AddDialogActivity extends Activity implements OnClickListener { private LinearLayout layout01, layout02, layout03; int sexStr; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dialog); initView(); } /** * 初始化组件 */ private void initView() { // 得到布局组件对象并设置监听事件 layout01 = (LinearLayout) findViewById(R.id.llayout01); layout02 = (LinearLayout) findViewById(R.id.llayout02); layout03 = (LinearLayout) findViewById(R.id.llayout03); layout01.setOnClickListener(this); layout02.setOnClickListener(this); layout03.setOnClickListener(this); } @Override public boolean onTouchEvent(MotionEvent event) { finish(); return true; } @Override public void onClick(View v) { switch (v.getId()) { case R.id.llayout01: Intent intent = new Intent(this, AddPetActivity.class); startActivity(intent); finish(); break; case R.id.llayout02: Intent intent1 = new Intent(this, AddTerminalActivity.class); startActivity(intent1); finish(); break; case R.id.llayout03: Intent intent2 = new Intent(this, MipcaActivityCapture.class); startActivity(intent2); finish(); break; default: break; } } }
最后在AndroidManifest文件里面声明
<activity android:name="com.cnmobile.beibei.activity.AddDialogActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />