2016-05-31 39 views
0

在Android中,我想在主屏幕上以編程方式製作文件夾,如乾淨大師做遊戲助推器或MyJio應用程序將其所有應用程序放在一個文件夾中。我嘗試使用Live文件夾,但不推薦使用,也不適用於最新的Android版本。 它是一個小部件,或者我不明白這個,請幫我理解這一點。在此先感謝在主屏幕上創建文件夾我可以在網格中放置一些圖標

+0

乾草你有沒有得到你的答案? –

+0

是的。感謝您的回答。 –

回答

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(); 
     } 
    }); 
}} 

的test.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> 
0

您是否在尋找類似這樣Assistive Touch,浮動按鈕,將適用於所有應用程序的頂部或想要創建簡單的文件夾 這是唯一的主屏幕上訪問的東西嗎?

+1

我想在主屏幕上以編程方式創建文件夾,並且想要在該文件夾上顯示圖標並且圖標應該可點擊 –

相關問題