1,Toast
// 登录成功之后跳转到home Toast.makeText(getApplicationContext(), "登陆成功!", Toast.LENGTH_SHORT).show();
2,简单提示框
AlertDialog.Builder builder = new Builder(home.this); builder.setMessage("确定要退出吗?"); builder.setTitle("提示"); builder.setPositiveButton("确认", new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); home.this.finish(); //关闭掉Activity } }); builder.setNegativeButton("取消", new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show();
3,处理返回按钮
/*处理返回按钮的问题*/ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { dialog(); return false; } return false; }
4,屏幕旋转
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="vertical" android:fadingEdge="vertical"> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <!--其他布局加到这里--> </LinearLayout> </ScrollView>