1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

ListView problem


Last Updated:

  1. captsisko

    captsisko New Member This Topic's Starter

    Joined:
    Jul 21, 2010
    Messages:
    2
    Likes Received:
    0
    Hi all,

    I am following a tutorial from a book on ListViews but while my activity launches just fine, my menu ListView does not display.

    Can anyone help a newbie and tell me what maybe wrong with the following code?

    package com.androidbook.triviaquiz;

    import android.os.Bundle;
    import android.util.Log;
    import android.widget.ArrayAdapter;
    import android.widget.ListView;

    public class QuizMenuActivity extends QuizActivity {
    private final String LOGID = "Track";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu);

    Log.i(LOGID, "Begining!");

    String[] items = new String[] {"test#1","test#2","test3","test#4"} ;
    ListView menuList = (ListView)findViewById(R.id.ListView_Menu);
    // By using setAdpater method in listview we an add string array in list.
    menuList.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1 , items));


    Log.i(LOGID, "Reaching this point!");
    }

    /*private String[] items = new String[] {"test#1","test#2","test3","test#4"} ;*/
    }
     

    Advertisement

Share This Page

Loading...