0

あるアクティビティでアプリをインストールしましたが、最初のアクティビティでチェックされたアプリのみを一覧表示する別のアクティビティがあります。3つの問題があります.1つ目は、2番目のアクティビティでこのようなことを示しています こんにちは

名前やアイコンの代わりに、このようにアプリを表示します。そのために何ができますか?

ご覧のとおり、2番目に重複が表示されます。チェックボックスがないため、最初のアクティビティでアプリが 2 回選択された場合にアプリを削除する方法がわかりません

3番目に、これを使用して、上の画像で選択したアクティビティを起動しています

    Intent newIntent = getPackageManager().getLaunchIntentForPackage(getPackageName());
    startActivity(newIntent);

それは私の最初の活動を開始するだけです。getPackageName() のスペースには何を書く必要がありますか?

必要に応じて、最初と 2 番目のアクティビティのコードを投稿します。ありがとう。

これが私のAppInfoAdapterです

public class AppInfoAdapter extends BaseAdapter {
private Context mContext;
private List<?> mListAppInfo;
private PackageManager mPackManager;

public AppInfoAdapter(Context c, List<?> list, PackageManager pm) {
    mContext = c;
    mListAppInfo = list;
    mPackManager = pm;
}

@Override
public int getCount() {
    return mListAppInfo.size();
}

@Override
public Object getItem(int position) {
    return mListAppInfo.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // get the selected entry
    ApplicationInfo entry = (ApplicationInfo) mListAppInfo.get(position);

    // reference to convertView
    View v = convertView;

    // inflate new layout if null
    if(v == null) {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        v = inflater.inflate(R.layout.lvrowlayout, null);
    }

    // load controls from layout resources
    ImageView ivAppIcon = (ImageView)v.findViewById(R.id.ivIcon);
    TextView tvAppName = (TextView)v.findViewById(R.id.tvName);
    TextView tvPkgName = (TextView)v.findViewById(R.id.tvPack);

    // set data to display
    ivAppIcon.setImageDrawable(entry.loadIcon(mPackManager));
    tvAppName.setText(entry.loadLabel(mPackManager));
    tvPkgName.setText(entry.packageName);

    // return view
    return v;
  }

ここはvrowlayout

 <LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="?android:attr/listPreferredItemHeight"
 android:padding="5dip" 
 >

<ImageView
  android:id="@+id/ivIcon"
  android:layout_width="wrap_content"
  android:layout_height="fill_parent"
  android:layout_marginRight="5dip"
  android:scaleType="center"
/>

<LinearLayout
  android:orientation="vertical"
  android:layout_width="0dip"
  android:layout_height="fill_parent"
  android:layout_weight="1"    
 >

  <TextView
      android:id="@+id/tvName"
      android:layout_width="fill_parent"
      android:layout_height="0dip"
      android:layout_weight="1"
      android:gravity="center_vertical"         
  />

  <TextView
      android:id="@+id/tvPack"
      android:layout_width="fill_parent"
      android:layout_height="0dip"
      android:layout_weight="1"
      android:singleLine="true"
      android:ellipsize="marquee"         
  />

  </LinearLayout>


</LinearLayout>
4

1 に答える 1