• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help listView and onClickListener

ok so here is what i have so far

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);
};
}

}



now im guessing that there is something wrong with this because whenever i click on an item in the list nothing happens. anyone know how to fix this or what im doing wrond? thanks.
 
It could just be me, could be that I dont know how to properly add the code, but im not having any luck. Will try a bit more. Thanks though.
 
Back
Top Bottom