开发者

ListActivity adding images?

开发者 https://www.devze.com 2023-01-02 18:38 出处:网络
i have a following ListActivity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

i have a following ListActivity:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Get Strings from res/strings.xml
    String items[] = { getString(R.string.mainMenu_1),
            getString(R.string.mainMenu_2), getString(R.string.mainMenu_3),
            getString(R.string.mainMenu_4), getString(R.string.mainMenu_5)};
    strings = items;

    ListAdapter listAdapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, items);
    setListAdapter(listAdapter);
}

Displaying it and reacting to user cli开发者_StackOverflow社区cks works great, now I want to add some pictures before the text (like "Settings"). can someone explain me how to do this? (How to get pictures from res/drawable isn needed to get explained ;-))

greets, poeschlorn


You have to make your own ListAdapter. Here's a fine tutorial about this: http://www.anddev.org/novice-tutorials-f8/iconified-textlist-the-making-of-t97.html?sid=57c1096099cb666b386eb4ab65aba0c6

0

精彩评论

暂无评论...
验证码 换一张
取 消