首页 新闻 会员 周边 捐助

蠢新 安卓 GridView 添加button报错 求解

0
[已关闭问题] 关闭于 2016-09-09 16:04

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

蠢新求解决方法

 

 

 

咕咕叽的主页 咕咕叽 | 菜鸟二级 | 园豆:214
提问于:2016-09-09 14:35
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册