English 中文(简体)
使用BaseAdapter填充GridView
原标题:Using BaseAdapter to populate GridView
  • 时间:2011-06-01 14:28:48
  •  标签:
  • android

I am having some difficulty in getting my implementation of a BaseAdapter working to populate a GridView. I ve a few questions around the workings of the BaseAdapter, based on the example here: http://developer.android.com/resources/tutorials/views/hello-gridview.html

在我的实现中,我的BaseAdapter.getCount()方法返回130。因此,我希望getView()方法在每个计数中被调用一次。然而,据我所知,getView()只被调用了大约70次。。。。为什么会这样?

如果getView()用于在网格中的每个位置构造View对象,那么返回object的getItem()的目的是什么?

最后,我希望我的网格宽10列,高13行。为了实现这一点,我是否只将android:numColumns属性设置为10?

感谢您在理解这一点时提供的任何帮助。

谢谢

问题回答
  • 然而,据我所知,getView()只被调用了大约70次。。。。为什么会这样

    它在视图渲染到屏幕时生成视图

  • 如果getView()用于在网格中的每个位置构造View对象,那么返回object的getItem()的目的是什么

getItem(int position)
Get the data item associated with the specified position in the data set.

正如描述所说,它返回与该位置相关联的基础数据,而不是相同位置的View

  • To achieve this, do I just set the android:numColumns attribute to be 10?

android:numColumns setNumColumns(int)定义要显示的列数。

The description is quite explicit here.
BTW, this last question is one that you could easily test yourself rather than asking here...





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签