I got the following Fragment
public static class DummySectionFragment extends Fragment {
ListView msgList;
ArrayListdetails;
AdapterView.AdapterContextMenuInfo info;
public void addVertretung (String Fach, String Raum, String Farbe) {
StundenplanDetail Detail;
Detail = new StundenplanDetail();
Detail.setFach(Fach);
Detail.setRaum(Raum);
Detail.setFarbe(Farbe);
details.add(Detail);
}
/**
* The fragment argument representing the section number for this
* fragment.
*/
XMLParser parser = new XMLParser();
String xml = null;
public static final String ARG_SECTION_NUMBER = "section_number";
public void loadArray (String dayArray) {
}
public DummySectionFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try{
byte[] inputBuffer = new byte[20000];
File inputFile = new File("sdcard/Android/data/com.approfi.woehlerschule/data.woehler");
FileInputStream fileInputStream = new FileInputStream(inputFile);
fileInputStream.read(inputBuffer);
xml = new String(inputBuffer);
fileInputStream.close();
}catch(IOException e){
Log.d("Fehler:", e.toString());
}
View rootView = inflater.inflate(
R.layout.fragment_stundenplan_dummy, container, false);
if(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)).equals("1")){
int splitpos1 = xml.indexOf(""); ") + 9;
int splitpos2 = xml.indexOf("
String xml2 = xml.substring(splitpos1, splitpos2);
org.w3c.dom.Document doc = parser.getDomElement(xml2);
NodeList nl = doc.getElementsByTagName("Stunde");
for (int i = 0; i < nl.getLength(); i++) {
Element e = (Element)nl.item(i);
String Fach = parser.getValue(e, "Fach"); // name child value
String Raum = parser.getValue(e, "Raum"); // cost child value
String Farbe = parser.getValue(e, "Farbe"); // description child value
Log.d("Fail:", Fach + Raum + Farbe);
}
}
/*if(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)).equals("2")){
ListView listViewStundenplan = (ListView) rootView.findViewById(R.id.listViewStundenplan);
ArrayAdapterarrayAdapter = new ArrayAdapter (getActivity(), R.layout.list_item_stundenplan, dienstagArray);
listViewStundenplan.setAdapter(arrayAdapter);
}
if(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)).equals("3")){
ListView listViewStundenplan = (ListView) rootView.findViewById(R.id.listViewStundenplan);
ArrayAdapterarrayAdapter = new ArrayAdapter (getActivity(), R.layout.list_item_stundenplan, mittwochArray);
listViewStundenplan.setAdapter(arrayAdapter);
}
if(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)).equals("4")){
ListView listViewStundenplan = (ListView) rootView.findViewById(R.id.listViewStundenplan);
ArrayAdapterarrayAdapter = new ArrayAdapter (getActivity(), R.layout.list_item_stundenplan, donnerstagArray);
listViewStundenplan.setAdapter(arrayAdapter);
}
if(Integer.toString(getArguments().getInt(ARG_SECTION_NUMBER)).equals("5")){
ListView listViewStundenplan = (ListView) rootView.findViewById(R.id.listViewStundenplan);
ArrayAdapterarrayAdapter = new ArrayAdapter (getActivity(), R.layout.list_item_stundenplan, freitagArray);
listViewStundenplan.setAdapter(arrayAdapter);
}
*/
msgList = (ListView) rootView.findViewById(R.id.listViewStundenplan);
msgList.setAdapter(new StundenplanAdapter(details, this));
return rootView;
}
}
And that Adapter for my List View
public class StundenplanAdapter extends BaseAdapter {
private ArrayList_data;
Context _c;
StundenplanAdapter (ArrayListdata, Context c){
_data = data;
_c = c;
}
public int getCount() {
return _data.size();
}
public Object getItem(int position) {
return _data.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)_c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.list_item_stundenplan, null);
}
TextView fachText = (TextView)v.findViewById(R.id.textViewStundenplanFach);
TextView raumText = (TextView)v.findViewById(R.id.textViewStundenplanRaum);
View colorBlock = (View)v.findViewById(R.id.colorBlockStundenplan);
StundenplanDetail msg = _data.get(position);
fachText.setText(msg.fach);
raumText.setText(msg.raum);
colorBlock.setBackgroundColor(37000000);;
return v;
}
}
Now the problem is, that eclipse tells me that The constructor StundenplanAdapter(ArrayList
but i want to use my custom adapter. Every thing works. The List View
in my Fragment and the Custom adapter
but not if I want to use the custom adapter in my fragment-listview
I hope you can help me thanks in advance, MoBr114
.
stackoverflow.comm
No comments:
Post a Comment