小编cit*_*cit的帖子

为什么getView在SeparatedListAdapter上返回错误的convertView对象?

我根据我的需要改编了Jeff Sharkey的SeparatedListAdapter并得到了这样的结果:

public class SeparatedListAdapter<T> extends BaseAdapter {

    @SuppressWarnings("unused")
    private final String LOG_TAG = getClass().getSimpleName();

    public final static int TYPE_SECTION_HEADER = 0;

    public final Map<T, Adapter> sectionAdapters;
    public final ArrayAdapter<T> headerAdapter;

    public SeparatedListAdapter(ArrayAdapter<T> headerAdapter) {
        super();
        this.sectionAdapters = new LinkedHashMap<T,Adapter>();
        this.headerAdapter = headerAdapter;
    }

    public void addSection(T section, Adapter adapter) {
        this.headerAdapter.add(section);
        this.sectionAdapters.put(section, adapter);
    }

    public void clearSections() {
        this.headerAdapter.clear();
        this.sectionAdapters.clear();
    }

    @Override
    public int getCount() {
        // total together all sections, plus one for each section header
        int total …
Run Code Online (Sandbox Code Playgroud)

android listview android-arrayadapter convertview

14
推荐指数
1
解决办法
5724
查看次数

iOS:当我将AppDelegate.h包含到另一个头文件中时,什么可能导致Xcode编译器抛出错误?

我正在尝试#import我的"AppDelegate.h"到同一项目的另一个头文件中,以便访问我的iOS项目的AppDelegate的方法.

所以,我的头文件看起来像这样:#import

#import "DataProvider.h"
#import "MyAppDelegate.h"

@interface MyViewController : UIViewController <UITextFieldDelegate, UIAlertViewDelegate> {
...
}
Run Code Online (Sandbox Code Playgroud)

我想像我这样使用我的AppDelegate:

MyAppDelegate* appDelegate = (MyAppDelegate*)[UIApplication sharedApplication].delegate;
[appDelegate doSomething];
Run Code Online (Sandbox Code Playgroud)

但是,只要我#import"MyAppDelegate.h",编译器就会抛出很多(无关的)错误,比如

Cannot find interface declaration for 'MyOtherViewController', superclass of 'MyOtherViewController2' 
Run Code Online (Sandbox Code Playgroud)

问题是:我可以在其他标题中包含我的AppDelegate.我无法弄清楚可能存在的差异.请帮我弄清楚是什么原因引起的!非常感谢!

PS:这种情况发生在GCC以及新的LLVM上.

compiler-construction import objective-c ios

0
推荐指数
1
解决办法
1091
查看次数