我创建了一个作为主屏幕的启动器应用程序,其中有许多图标,每个图标代表一个不同的应用程序。我想知道如何在这些图标下显示每个应用程序的名称。这是显示图标的类:
ImageAdapter.java
package com.seniorDesign.main.project;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class ImageAdapter extends BaseAdapter{
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(mContext);
//imageView.setBackgroundColor(Color.BLACK);
imageView.setLayoutParams(new GridView.LayoutParams(250,200));
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
imageView.setPadding(8,8,8,8);
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.phone, R.drawable.calendar, R.drawable.calculator,
R.drawable.gallery, R.drawable.browser, R.drawable.email,
R.drawable.map, R.drawable.sms, R.drawable.camera, R.drawable.contacts,
R.drawable.notepad_icon
};
}
任何帮助将不胜感激。谢谢