Im opening a ListActivity with an xml called list with a ListView named list. I have an array adapter set up and working in another activity (not a list activity though, just a normal activity) and it all works fine. When I try to open this list activity though, I get an error saying that I need a ListView with the id android.R.id.list. I have that ListView though. What is my problem?
Code for my AlertDialog I am trying to get to work.
public void onListItemClick(ListView parent, View v, int position, long id)
{
Context mContext = getApplicationContext();
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle(getText(position));
ImageView image = (ImageView) alertDialog.findViewById(R.id.image);
image.setImageResource(R.drawable.hydrogen);
}
and this was another code i had trying to get it to work
public void onListItemClick(ListView parent, View v, int position,
long id) {
new AlertDialog.Builder(Anions.this);
alertDialog.setContentView(R.layout.custom_dialog);
alertDialog.setTitle(anions[position]);
ImageView image = (ImageView) alertDialog.findViewById(R.id.image);
image.setImageResource(R.drawable.hydrogen);
alertDialog.setButton("Done", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int which){
return;
}
}
);
alertDialog.show();
}