当我试图执行该代码并运行它时,它将不显示任何代码。
下面是我的适配器代码:
public class MyAdapter extends BaseAdapter {
private Context mContext;
public MyAdapter(Context c) {
mContext = c;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
我正在尝试使用自定义图像适配器与GridView和fragment结合使用。当我只对一个Activity使用几乎相同的代码时,代码工作得很好。但是当我使用fragment时,图像就不再显示了。以下是相关代码
注意:缩略图是片段类的全局变量
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View ro
我正在创建游戏应用程序。当我单击在另一个GridView上显示的GridView项时,我使用的是图像和图像,这是我想要匹配图像徽标和文本视图字符串(徽标名称)的另一个活动。我已经做了一些逻辑,但是当我运行应用程序时,它会转到logic语句。
这是我的密码。
GridView活动代码:
public class GridView_Activity extends Activity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
我必须创建一个网格视图,其中包含驻留在SDCard上的特定文件夹的图像。文件夹的路径是"/sdcard/images/“。我尝试使用此代码,应用程序加载时间太长,并且它只显示一张图像。
public class ImAdapterh extends BaseAdapter{
File dir=new File(Environment.getExternalStorageDirectory(),"/myImages/");
int count=dir.list().length;
String[] fileNames = dir.list()
我试图在片段中创建一个网格视图。我已经实现了适配器类和各自的overriden方法。但是,在运行时,它会抛出一个异常:
gridView.setOnItemClickListener (this);
声明gridView对象是空指针。
下面是我的代码(非常类似于):
public static class OcrOverrideFragment extends Fragment implements AdapterView.OnItemClickListener {
// The Adaptor Class for the grid view
public class Ima
我只是从drawable检索图像并使用base adapter,但是fragment没有显示任何image。以下是我的代码..。是否有任何问题或逻辑错误...有人能告诉我吗!这是片段代码..
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.
我使用毕加索来填充我的GridView,使用以下代码:
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
// if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(n