So Im trying to populate a Dialog with a list of Folders that I get from an API, once the user clicks on a folder, I again populate the Dialog with its subfolders etc. But Im not quite sure how everything fits together. So far the Dialog is displayed, now I need to add the actual content.
@Override
protected View onCreateDialogView() {
LayoutInflater inflater = ((SettingsActivity) ctx).getLayoutInflater();
View vw = inflater.inflate(R.layout.channel_content_view, null);
ListView lv = (ListView) vw.findViewById(android.R.id.list);
File[] files = ChannelHandler.getChannels();
HiddenChannelsListAdapter adapter = new HiddenChannelsListAdapter(ctx, files);
lv.setAdapter(adapter);
return vw;
}
Im not sure how that Class HiddenChannelsListAdapter must look.
This is what I have sofar:
package com.example.tvrplayer;
import java.io.File;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
public class HiddenChannelsListAdapter extends BaseAdapter {
public HiddenChannelsListAdapter(Context ctx, File[] files) {
// TODO Auto-generated constructor stub
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
View view = null;
Log.i("ADAPTER", "Hello");
return view;
}
}
When I try and open the dialog now, it gets a NullPointerException, that I asume is because the adapter is not doing anything but returning null.
What does an adapter return? Where does it return it? Im quite confused at the moment