I'm trying to do something very simple: create a frequently asked questions listview, and when a question is clicked, the answer appears in a textview. I created two string arrays for questions and answers, and each element is listed as an item. There are 5 q's and 5 a's. Right now the questions are being displayed correctly in a listview, but the onclick isn't working. What is wrong??
package freq.asked;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class FreqActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//displays all elements of questions array in listview
setListAdapter(ArrayAdapter.createFromResource(getApplicationContext(),
R.array.questions, R.layout.main));
}
public void onItemClick(AdapterView<?> arg0, TextView v, int position, long id) {
String[] ans = getResources().getStringArray(R.array.answers);
for (int i=0; i<6; i++) {
//should display answer to question in textview
v.setTag(ans[i]);
}
}
}