Problem with Lab3 - AdvancedJokeList
<p>I've got a problem with Lab3 - AdvancedJokeList. You can see the lab here <a href="https://sites.google.com/site/androidappcourse/labs/lab-3" rel="nofollow">Lab3 - AdvancedJokeList</a></p>

<p>At the part 3.2 "Make AdvancedJokeList Activity Use ListView", I've replaced the ScrollView and LinearLayout inside by a ListView on file "advanced.xml" like this:</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;

&lt;LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"&gt;
    &lt;Button
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="@string/button"
        android:id="@+id/addJokeButton" /&gt;
    &lt;EditText
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:singleLine="true"
        android:gravity="left"
        android:id="@+id/newJokeEditText" /&gt;
&lt;/LinearLayout&gt;

&lt;ListView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:drawSelectorOnTop="false"
    android:id="@+id/jokeListViewGroup"&gt;    
&lt;/ListView&gt;
</code></pre>

<p></p>

<p>And I've modified the file "AdvancedJokeList.java" like this:</p>

<pre><code>package edu.calpoly.android.lab3;

import java.util.ArrayList;

import edu.calpoly.android.lab3.R;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.InputType;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;

public class AdvancedJokeList extends Activity {

    protected LinearLayout root_layout;
    protected LinearLayout top_layout;
    private int color_counter = 0;

    /**
     * Contains the name of the Author for the jokes.
     */
    protected String m_strAuthorName;

    /**
     * Contains the list of Jokes the Activity will present to the user.
     **/
    protected ArrayList&lt;Joke&gt; m_arrJokeList;

    /**
     * Adapter used to bind an AdapterView to List of Jokes.
     */
    protected JokeListAdapter m_jokeAdapter;

    /**
     * ViewGroup used for maintaining a list of Views that each display Jokes.
     **/
    //protected LinearLayout m_vwJokeLayout;
    protected ListView m_vwJokeLayout;
    /**
     * EditText used for entering text for a new Joke to be added to
     * m_arrJokeList.
     **/
    protected EditText m_vwJokeEditText;

    /**
     * Button used for creating and adding a new Joke to m_arrJokeList using the
     * text entered in m_vwJokeEditText.
     **/
    protected Button m_vwJokeButton;

    /**
     * Background Color values used for alternating between light and dark rows
     * of Jokes.
     */
    protected int m_nDarkColor;
    protected int m_nLightColor;

    /**
     * Context-Menu MenuItem ID's
     * IMPORTANT: You must use these when creating your MenuItems or the tests
     * used to grade your submission will fail.
     */
    protected static final int REMOVE_JOKE_MENUITEM = Menu.FIRST;
    protected static final int UPLOAD_JOKE_MENUITEM = Menu.FIRST + 1;

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

        // TODO
        initLayout();

        m_arrJokeList = new ArrayList&lt;Joke&gt;();
        m_jokeAdapter = new JokeListAdapter(getApplicationContext(), m_arrJokeList);
        m_vwJokeLayout.setAdapter(m_jokeAdapter);

        setContentView(R.layout.advanced);
        String[] jokestring = this.getResources().getStringArray(R.array.jokeList);
        for(String str : jokestring) {
            Joke temp = new Joke(str, "");
            addJoke(temp);
        }
        initAddJokeListeners();


    }

    /**
     * Method is used to encapsulate the code that initializes and sets the
     * Layout for this Activity.
     */
    protected void initLayout() {
        // TODO
        m_vwJokeLayout = (ListView)findViewById(R.id.jokeListViewGroup);
        //m_vwJokeLayout = (LinearLayout)findViewById(R.id.jokeListViewGroup);
        /*m_vwJokeLayout = new LinearLayout(this);
        m_vwJokeLayout.setOrientation(LinearLayout.VERTICAL);
        ScrollView Sv = new ScrollView(this);
        m_vwJokeButton = new Button(this);
        m_vwJokeButton.setText("Add Joke");
        m_vwJokeEditText = new EditText(this);
        m_vwJokeEditText.setSingleLine();
        m_vwJokeEditText.setInputType(InputType.TYPE_NULL);
        m_vwJokeEditText.setLayoutParams(new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));

        root_layout = new LinearLayout(this);
        root_layout.setOrientation(LinearLayout.VERTICAL);
        top_layout = new LinearLayout(this);
        top_layout.setOrientation(LinearLayout.HORIZONTAL);

        Sv.addView(m_vwJokeLayout);
        top_layout.addView(m_vwJokeButton);
        top_layout.addView(m_vwJokeEditText);
        root_layout.addView(top_layout);
        root_layout.addView(Sv);
        setContentView(root_layout);*/
    }

    /**
     * Method is used to encapsulate the code that initializes and sets the
     * Event Listeners which will respond to requests to "Add" a new Joke to the
     * list.
     */
    protected void initAddJokeListeners() {
        // TODO
        m_vwJokeButton = (Button)findViewById(R.id.addJokeButton);
        m_vwJokeEditText = (EditText)findViewById(R.id.newJokeEditText);
        m_vwJokeEditText.setInputType(InputType.TYPE_NULL);
        m_vwJokeButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                if(m_vwJokeEditText.getText().toString().equals("") == false)
                {
                    String str = m_vwJokeEditText.getText().toString();
                    m_vwJokeEditText.setText("");
                    Joke temp = new Joke(str, "");
                    addJoke(temp);

                    //InputMethodManager imm = (InputMethodManager)
                    //getSystemService(Context.INPUT_METHOD_SERVICE);
                    //imm.hideSoftInputFromWindow(m_vwJokeEditText.getWindowToken(), 0);

                }
            }
        });
    }

    /**
     * Method used for encapsulating the logic necessary to properly add a new
     * Joke to m_arrJokeList, and display it on screen.
     * 
     * @param joke
     *            The Joke to add to list of Jokes.
     */
    protected void addJoke(Joke joke) {
        // TODO

        /*TextView TV=new TextView(this);
        TV.setTextSize(16);
        if(color_counter % 2 == 0)
            TV.setBackgroundColor(this.getResources().getColor(R.color.dark));
        else
            TV.setBackgroundColor(this.getResources().getColor(R.color.light));
        color_counter ++;
        m_vwJokeLayout.addView(TV);
        TV.setText(joke.toString());*/

        JokeView JV = new JokeView(this, joke);
        if(color_counter % 2 == 0)
            JV.setBackgroundColor(this.getResources().getColor(R.color.dark));
        else
            JV.setBackgroundColor(this.getResources().getColor(R.color.light));
        color_counter ++;


        m_arrJokeList.add(JV);


    }

    /**
     * Method used to retrieve Jokes from online server. The getJoke script
     * takes a single optional parameter, which should be encode in "UTF-8".
     * This parameter allows tells script to only retrieve Jokes whose author
     * name matches the value in the parameter.
     * 
     * param-1) "author": The author of the joke.
     * 
     * URL: http://simexusa.com/aac/getJokes.php?
     * 
     */
    protected void getJokesFromServer() {
        // TODO
    }

    /**
     * This method uploads a single Joke to the server. This method should test
     * the response from the server and display success or failure to the user
     * via a Toast Notification
     * 
     * The addJoke script on the server requires two parameters, both of which
     * should be encode in "UTF-8":
     * 
     * param-1) "joke": The text of the joke.
     * 
     * param-2) "author": The author of the joke.
     * 
     * URL: http://simexusa.com/aac/addJoke.php?
     * 
     * @param joke
     *            The Joke to be uploaded to the server.
     * 
     */
    protected void uploadJokeToServer(Joke joke) {
        // TODO
    }

}
</code></pre>

<p>The problem here is that I've tried lots of ways to add a JokeView into a ListView instead a LinearLayout but no way succeeded.</p>
