ListView created programmatically - emptyView doesn't show

Posted by Yorick on Stack Overflow See other posts from Stack Overflow or by Yorick
Published on 2010-05-08T07:53:12Z Indexed on 2010/05/08 7:58 UTC
Read the original article Hit count: 190

Filed under:
|
|

I've created custom ListView programmatically, and set view to show when ListAdapter is empty but nothing shows on the screen in that case, what can be wrong?

    public PlayerList(Context context, Activity activity) {
    super(context);
    mParent = activity;
    setOnItemClickListener(
        new OnItemClickListener() {    
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {   ...   } };

    List<PlayerInfo> players;
    players = getPlayerList(); // here size of players == 0
    setAdapter(new PlayersAdapter(this.getContext(), R.id.player_name, players));

    LayoutInflater vi = (LayoutInflater)mParent.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    emptyView = vi.inflate(R.layout.empty_view, null); // emptyView is View, and member of PlayerList

    this.setEmptyView(emptyView);
}

© Stack Overflow or respective owner

Related posts about android

Related posts about listview