Android ランチャーを作成しています。すべてのアプリをグリッドビューにロードする方法を知る必要があります。電卓などのシステム関連のものもすべて表示されるようにします。どうやってやるの?私は解決策なしで長い間検索しています。私を助けてください、そしてどうもありがとう!
Java コード:
package com.mysoftware.mysoftwareos.launcher;
import java.util.List;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.GridView;
import android.widget.LinearLayout;
public class AllAppsActivity extends Activity {
LinearLayout allappsLayout;
GridView allappsGridView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.allapps_screen);
//Import views
allappsLayout = (LinearLayout)findViewById(R.id.allappsLayout);
allappsGridView = (GridView)findViewById(R.id.allappsGridView);
//Setup animation for the main layout
Animation a = AnimationUtils.loadAnimation(this, R.anim.fadeout);
a.reset();
allappsLayout.clearAnimation();
allappsLayout.startAnimation(a);
//Load all apps into the apptray
}
}
私のxmlレイアウト:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/allappsLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/wallpaper"
android:orientation="vertical" >
<GridView
android:id="@+id/allappsGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="3" >
</GridView>
</LinearLayout>