当前位置:首页 » 安卓系统 » android滑出菜单

android滑出菜单

发布时间: 2022-12-19 08:15:50

‘壹’ android 点击按钮时显示菜单应怎样实现

点击button弹出对话框菜单

importandroid.app.Activity;

importandroid.app.AlertDialog;

importandroid.content.DialogInterface;

importandroid.os.Bundle;

importandroid.view.View;

importandroid.view.View.OnClickListener;

importandroid.widget.Button;

{

privateButtonbutton;

/**.*/

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

button=(Button)findViewById(R.id.button1);

button.setOnClickListener(newOnClickListener(){

@Override

publicvoidonClick(Viewarg0){

newAlertDialog.Builder(choice.this)

.setTitle("choice")

.setItems(R.array.str_body,newDialogInterface.OnClickListener(){

@Override

publicvoidonClick(DialogInterfacearg0,intarg1){

//TODOAuto-generatedmethodstub

String[]aryshop=getResources().getStringArray(R.array.str_body);

newAlertDialog.Builder(choice.this)

.setMessage(aryshop[arg1])

.setNegativeButton("ok",newDialogInterface.OnClickListener(){

@Override

publicvoidonClick(DialogInterfacearg0,intarg1){

//TODOAuto-generatedmethodstub

}

}).show();

}

}).show();

//TODOAuto-generatedmethodstub

}});

}

}

菜单项

<?xmlversion="1.0"encoding="utf-8"?>

<resources>

<stringname="hello">HelloWorld,choice!</string>

<stringname="app_name">ChoiceMenu</string>

<stringname="strtitle">按我选择:</string>

<stringname="str">你选择的是:</string>

<arrayname="str_body">

<item>选项1</item>

<item>选项2</item>

<item>选项3</item>

<item>选项4</item>

<item>选项5</item>

<item>选项6</item>

</array>

</resources>

‘贰’ android怎么实现类似qq那样的右滑出现侧拉菜单

Android 实现类似QQ侧滑菜单,实现左右侧滑 源码。具有iOS 7/8 parallax effect 风格的侧边菜单,类似于最新版qq的菜单效果。ReisdeMenu 创意灵感来自于Dribbble1还有2,而这个是Android版的ResideMenu,在视觉效果上部分参考了iOS版的RESideMenu

‘叁’ android的这种弹出菜单(窗口)怎么实现

可以用popupWindow
public class PopUpActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LayoutInflater inflater = LayoutInflater.from(this);
// 引入窗口配置文件
View view = inflater.inflate(R.layout.main2, null);
// 创建PopupWindow对象
final PopupWindow pop = new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, false);
Button btn = (Button) findViewById(R.id.btn);
// 需要设置一下此参数,点击外边可消失
pop.setBackgroundDrawable(new BitmapDrawable());
//设置点击窗口外边窗口消失
pop.setOutsideTouchable(true);
// 设置此参数获得焦点,否则无法点击
pop.setFocusable(true);

}
}
popupWindow.showAsDropDown(v);让它出现在上方标题栏的下方
布局里可以写成listview,也可以写成死布局
还有就是ActionBar,但个人感觉ActionBar没有popupWindow灵活,反正我一般这种情况都会用popupWindow,看个人爱好

‘肆’ Android/Iphone怎么实现左右滑动显示左右导航菜单

Android上有一个控件叫做ViewPager,该控件可以根据item的多少实现左右滑动的效果。Android上还有一个东西叫做Fragment,这是一个依赖于Activity而又独立的页面。综合这两个控件的特性,可以使用ViewPager+Fragment的方式,即在ViewPager里嵌入Fragment的方式,实现页面左右滑动的效果。

热点内容
海澜之家广告脚本 发布:2025-05-17 13:56:06 浏览:29
手文件夹恢复 发布:2025-05-17 13:53:32 浏览:992
linux怎么看进程 发布:2025-05-17 13:53:30 浏览:302
thinkphp字段缓存 发布:2025-05-17 13:52:01 浏览:574
山灵app安卓版如何设置 发布:2025-05-17 13:51:49 浏览:387
帆布压缩袋 发布:2025-05-17 13:26:27 浏览:457
c语言16进制表示方法 发布:2025-05-17 13:11:25 浏览:480
ftp单位 发布:2025-05-17 13:10:03 浏览:142
c语言编写n的阶乘 发布:2025-05-17 13:10:02 浏览:685
lockjava 发布:2025-05-17 13:02:08 浏览:311