xml A:
<ImageView
android:id="@+id/image"
android:layout_width="85dp"
android:layout_height="95dp"
android:layout_gravity="center"
android:scaleType="fitXY"
android:padding="4dp"
/>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
/>
xml B:
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" >
</GridView>
Activity 主体:
private GridView gridView;
private String[] titles = new String[]
{ "nata", "beat","coll", "dogg"};
private int[] images = new int[]{
R.drawable.image,~~~};
class PictureAdapter extends BaseAdapter {
private LayoutInflater inflater;
private List<Picture> pictures;
public PictureAdapter(String[] titles, int[] images, Context context) {
super();
pictures = new ArrayList<Picture>();
inflater = LayoutInflater.from(context);
for (int i = 0; i < images.length; i++) {
Picture picture = new Picture(titles[i], images[i]);
pictures.add(picture);
}
}...
如上:
在xml中添加button
<LinearLayout
android:layout_height="50dp"
android:layout_gravity="left"
>
<Button
android:id="@+id/nightbtn"
android:text="返回上一级"
/>
</LinearLayout>
没有绑定点击事件 就报错了
报错图贴不上来额
Activity 注册过了
百度后 试过几种添加button 都不行额
fatal exception :main
蠢新求解决方法