I am getting a resource not found issue in an app I am playing with, the id does exist in the view, and the correct view is being used. I have deleted the R file and regenerated but that hasn't helped. It compiles and appears the resource is found but at run time it errors when attempting to set text in the textview. Hopefully some one can point out what is causing this.
Here is the adapter code:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
SongHolder songHolder = null;
if(row == null)
{
LayoutInflater inflater = ((Activity)mContext).getLayoutInflater();
row = inflater.inflate(mLayoutResourceId, parent, false);
songHolder = new SongHolder();
songHolder.txtSongId = (TextView)row.findViewById(R.id.songid);
songHolder.txtName = (TextView)row.findViewById(R.id.name);
songHolder.txtArtist = (TextView)row.findViewById(R.id.artist);
songHolder.txtAlbum = (TextView)row.findViewById(R.id.album);
songHolder.txtNotes = (TextView)row.findViewById(R.id.notes);
row.setTag(songHolder);
}
else
{
songHolder = (SongHolder)row.getTag();
}
ClassSong song = mSongs.get(position);
//###############THE FOLLOWING LINE IS WHERE THE ERROR OCCURS###############
songHolder.txtSongId.setText(song.getSongID());
songHolder.txtName.setText(song.getName());
songHolder.txtArtist.setText(song.getArtist());
songHolder.txtAlbum.setText(song.getAlbum());
songHolder.txtNotes.setText(song.getNotes());
if(song.getAlbum() == "" || song.getAlbum() == null)
songHolder.txtAlbum.setVisibility(View.GONE);
else
songHolder.txtAlbum.setVisibility(View.VISIBLE);
if(song.getNotes() == "" || song.getNotes() == null)
songHolder.txtNotes.setVisibility(View.GONE);
else
songHolder.txtNotes.setVisibility(View.VISIBLE);
return row;
}
The xml for the view:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gat"
android:padding="0dip">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:textColor="#FFFFFF"
android:textSize="18sp"/>
<TextView android:id="@+id/songid"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:visibility="gone"
android:textColor="#FFFFFF"
android:textSize="18sp"/>
<TextView android:id="@+id/artist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:textColor="#517789"
android:textSize="15sp"/>
<TextView android:id="@+id/album"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:textColor="#517789"
android:textSize="12sp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/notes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#517789"
android:textSize="12sp"/>
</LinearLayout>
</LinearLayout>
and the code from the list activity that calls the adapter:
private void fillData() {
ClassSong song = new ClassSong(this);
ClassSongListAdapter adapter = new ClassSongListAdapter(this, R.layout.song_row, song.getAllSongs(this));
setListAdapter(adapter);
}
Also, when picking up the view in the holder it is found and has a value that is not null obviously. So it appears that the textview is found when added to the view holder but not when I attempt to set a value to it, if I comment out the songid line the other assignments work just fine. Anyone have any ideas?
Thanks.