如何将ImageView添加为ListView标头?

Gra*_*kos 4 android listview header

任何人都可以帮我找到如何将ImageView作为标题添加到ListView?

我的代码在这里:

LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View snapshot = inflater.inflate(R.layout.map_snapshot, null);

ListView channelsList = (ListView) findViewById(R.id.channelsList);
channelsList.addHeaderView(snapshot);
Run Code Online (Sandbox Code Playgroud)

到现在为止它什么也没显示

Iñi*_*igo 7

尝试通过父(ListView)作为参数来扩展标题视图:

ListView channelsList = (ListView) findViewById(R.id.channelsList);
View snapshot = inflater.inflate(R.layout.map_snapshot, channelList, false);
Run Code Online (Sandbox Code Playgroud)

然后,只需将其添加到ListView:

channelsList.addHeaderView(snapshot);
Run Code Online (Sandbox Code Playgroud)