English 中文(简体)
安德列:获得意见不正确 观点
原标题:Android: getView() does not return correct View object

我撰写了来自ArrayAdapter的习俗接触书。 让我们假设,名单仅有三个要素。 我在每打听电文的电话中都收发了字眼和信条。 我注意到,观点反对没有正确归还。 我在这里做了一些错误的事情?

private class ContactListAdapter extends ArrayAdapter<ContactItem> {
... ...
    @Override
    public View getView(int aPosition, View aConvertView, ViewGroup aParent) {
        Log.d(TAG, "Inside ContactListAdapter.getView()");
        if(aConvertView==null) {
             Log.d(TAG, "ConvertView is null");
             // Inflate view...
        }
        Log.d(TAG, "Pos: " + aPosition + " View: " + aConvertView.hashCode());
        return aConvertView;
    }

这里是初步意见生成的标志:

D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): ConvertView is null
D/ContactsActivity(  759): Pos: 0 View: 1156974184
D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): ConvertView is null
D/ContactsActivity(  759): Pos: 1 View: 1157007416
D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): ConvertView is null
D/ContactsActivity(  759): Pos: 2 View: 1157027832

当我点击名单上的第三点时,就会出现记录(不知道如何交换第一和最后元素的散射编码)。 我的Click方法仅仅使名单上的少数实体:

D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): Pos: 0 View: 1157027832
D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): Pos: 1 View: 1157007416
D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): Pos: 2 View: 1156974184

当我点击第二个要素时,标识:

D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): Pos: 0 View: 1156974184
D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): Pos: 1 View: 1157007416
D/ContactsActivity(  759): Inside ContactListAdapter.getView()
D/ContactsActivity(  759): Pos: 2 View: 1157027832

这一点一再得到观察,每次只交换头和最后入境的散射编码。 这可能是什么原因?

问题回答

兑换 观点被用来重复看待适应者的观点,因此,如果你展示一个名单,并假定你的屏幕能够显示一个时的5行,然后在5行中形成看法。 观点仍然无效,但当你下台时,您的适应者为您的适应者的观点提出了新的看法,因此,清单中的第六项内容可以重新使用。 1. 导言





相关问题
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 ...

热门标签