I keep getting an error when overriding my getview method. This is what I have:
public class UnwatchedEpisodesActivity extends ListActivity{
private String[] values = new String[]{"Row 1", "Row 2", "Row 3"};
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.episode_main);
setListAdapter(new EpisodeListAdapter());
}
private class EpisodeListAdapter extends ArrayAdapter<String>{
private LayoutInflater li = LayoutInflater.from(this.getContext());
public EpisodeListAdapter(){
super(UnwatchedEpisodesActivity.this, 0, values);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null){
convertView = li.inflate(R.layout.episode_row, parent, false);
}
((TextView) convertView.findViewById(R.id.text1)).setText(values[position]);
return convertView;
}
}
and my xml is this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/ep_layout"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:id="@android:id/text1" />
</LinearLayout>
(I also tried without the linearlayout, it makes no difference) I get this error.
You guys any idea?
Also another question: What should I do if I want to seperate the values in groups? I want a list to show something like:
-----------
first part
-----------
Row 1
Row 2
-----------
second part
-----------
Row 3
Obviously this is just an example; basically I want to know how to add those 'seperators'