Android Studio:无法生成已签名的APK
在尝试使用Android Studio生成签名apk时,我遇到以下错误:Android Studio:无法生成已签名的APK,android,android-studio,apk,android-install-apk,Android,Android Studio,Apk,Android Install Apk,在尝试使用Android Studio生成签名apk时,我遇到以下错误: Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.tokom.globol.CustomGrid) [Instantiatable] 我试图通过在课堂上使用super来解决这个问题,但它显示了红线错误 这里是CustomGrid.java package co
Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.tokom.globol.CustomGrid) [Instantiatable]
我试图通过在课堂上使用super来解决这个问题,但它显示了红线错误
这里是CustomGrid.java
package com.tokom.globol;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class CustomGrid extends BaseAdapter{
private Context mContext;
private final String[] web;
private final int[] Imageid;
public CustomGrid(Context c,String[] web,int[] Imageid ) {
mContext = c;
this.Imageid = Imageid;
this.web = web;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return web.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View grid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
grid = inflater.inflate(R.layout.grid_single, null);
} else {
grid = convertView;
}
TextView textView = (TextView) grid.findViewById(R.id.grid_text);
ImageView imageView = (ImageView)grid.findViewById(R.id.grid_image);
textView.setText(web[position]);
imageView.setImageResource(Imageid[position]);
return grid;
}
}
这就是我在mainActivity中对类的称呼:
CustomGrid adapter = new CustomGrid(MainActivity.this, web, imageId);
grid=(GridView)findViewById(R.id.grid);
grid.setAdapter(adapter);
任何帮助都将不胜感激,谢谢
Error:Error: This class should provide a default constructor (a public constructor with no arguments) (com.tokom.globol.CustomGrid) [Instantiatable]
这就是我们的线索!只需向CustomGrid类添加一个默认构造函数
public CustomGrid() {
}
这就是我们的线索!只需向CustomGrid类添加一个默认构造函数
public CustomGrid() {
}
这就是我们的线索!只需向CustomGrid类添加一个默认构造函数
public CustomGrid() {
}
这就是我们的线索!只需向CustomGrid类添加一个默认构造函数
public CustomGrid() {
}
您是否尝试添加BaseAdapter的默认构造函数
public CustomGrid(){}
@GoRoS感谢它成功了:)您尝试过添加BaseAdapter的默认构造函数吗public CustomGrid(){}
@GoRoS感谢它成功了:)您尝试过添加BaseAdapter的默认构造函数吗public CustomGrid(){}
@GoRoS感谢它成功了:)您尝试过添加BaseAdapter的默认构造函数吗public CustomGrid(){}
@GoRoS感谢它成功了:)在发布此答案前3分钟阅读问题的第一条评论;)正如你看到的,我已经定义了public CustomGrid(上下文c,字符串[]web,int[]Imageid){因此,如果我创建空构造函数,它将给出错误。在发布此答案前3分钟阅读问题的第一条注释;)正如你看到的,我已经定义了public CustomGrid(上下文c,字符串[]web,int[]Imageid){因此,如果我创建空构造函数,它将给出错误。请在发布此答案前3分钟阅读问题的第一条注释;)因为您可以看到,我已经定义了公共CustomGrid(上下文c,字符串[]web,int[]Imageid){因此,如果我创建空构造函数,它将给出错误。请在发布此答案前3分钟阅读问题的第一条注释;)因为您可以看到,我已经定义了公共CustomGrid(上下文c,字符串[]web,int[]Imageid){因此,如果我创建空构造函数,它将给出错误。