0

在 Android 中,我想以编程方式在主屏幕上创建文件夹,就像 为游戏助推器或 MyJio应用程序所做的清理大师一样,将其所有应用程序放在一个文件夹中。我尝试使用 Live 文件夹,但它已被弃用,并且在最新的 android 版本中也不适用于我。它是一个小部件还是我对此无法理解的内容,请帮助我理解这一点。提前致谢

4

2 回答 2

1

您可以使用对话框来执行此操作,使用多个应用程序图像创建应用程序图标并将其设置为您的应用程序图标,现在创建一个活动并将其注册到清单中,例如,我只显示两个按钮您可以在对话框布局中添加更多

    <activity android:name=".DialogActivity"
        android:theme="@android:style/Theme.DeviceDefault.Dialog">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

现在您的活动如下

public class DialogActivity extends Activity {

AlertDialog dialog;
LinearLayout mLinearLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.test);

    mLinearLayout = (LinearLayout) findViewById(R.id.test);
    mLinearLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    Window window = this.getWindow();
    window.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));


    AlertDialog.Builder builder = new AlertDialog.Builder(this);

    builder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User clicked OK button
        }
    });
    builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            // User cancelled the dialog
            dialog.dismiss();
            finish();
        }
    });
    dialog = builder.create();
    dialog.show();

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            finish();
        }
    });
}}

测试.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:id="@+id/test"
android:layout_height="match_parent"></LinearLayout>
于 2016-05-31T06:58:41.927 回答
0

您是否正在寻找类似Assistive Touch 之类的东西,一个可在所有应用程序顶部使用的浮动按钮,或者想要创建只能在主屏幕上访问的简单文件夹?

于 2016-05-31T07:17:24.793 回答