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

Apps Help listView and onClickListener

Amon Darthir

Newbie
Feb 4, 2010
27
0
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.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones