Hi. I am having trouble figuring out how to get my onListItemClick to
work. Here is my code.

package list.view;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;

public class ListView extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        setListAdapter(new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1, ANIONS));
        }

    public static final String[] ANIONS = new String[] {
        "Acetate", "Bromine", "Carbonate", "Chlorate", "Chloride",
        "Chlorite", "Chromate", "Cyanide", "Dychromate",
    };

    protected void onListItemClick(ListView l, View v, int position,
long id)
    {
    if (position == 0){
        setContentView(R.layout.acetate);
        };
    if (position == 1){
        setContentView(R.layout.bromine);
        };
    if (position == 2){
        setContentView(R.layout.carbonate);
        };
    if (position == 3){
        setContentView(R.layout.chlorate);
        };
                                                };

}

It seems like it should work but it never brings up the new .xml. Any
suggestions would be nice. Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to