0
我讀,因爲它有必要在每個類這樣的方法主要地方:是否需要類的主要方法?
public static void main(String args [ ]) { }
然而,沒有我在我的當前項目類都包含這樣的方法,到目前爲止,我的應用程序的經驗沒有問題......這是我的課程之一供參考。
public class GridAdapter extends BaseAdapter {
private final String[] classes = {"Database"}; // Sets the labels for each button
private Context mContext;
public GridAdapter(Context c) {
mContext = c;
}
public int getCount() { //autogenerated tab, returns length of an array.
return mThumbIds.length;
}
// The position an item is in in an array.
public Object getItem(int position) {
return mThumbIds[position];
}
// Gets the ID of each item in the array.
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) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView;
if (convertView == null) { // if it's not recycled, initialize some attributes
gridView = new View(mContext);
gridView = inflater.inflate(R.layout.gridset, null);
TextView textView = (TextView) gridView
.findViewById(R.id.label);
textView.setText(classes[position]);
ImageView imageView = (ImageView) gridView
.findViewById(R.id.img);
imageView.setImageResource(mThumbIds[position]);
} else {
gridView = convertView;
}
return gridView;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.img};
}
是因爲我擴展了某些東西(本例中是BaseAdapter)?現在,當前完成並實際運行的類有一個擴展,所以我想知道如果我的WIP類不需要main()方法。
沒有,那肯定是沒有必要有一個在所有類;只有在運行應用程序的入口點的類中才有必要。你在哪裏讀過這些? –
你從哪裏讀到的? –
不是。 Android中根本不需要public static void main(String args [])''。 – PPartisan