Created
December 20, 2011 03:21
-
-
Save acidsound/1500086 to your computer and use it in GitHub Desktop.
JSONObject를 위한 Custom ListAdapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.appsoulute.library; | |
import java.util.List; | |
import org.json.JSONObject; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.widget.ArrayAdapter; | |
public class CustomJSONListAdapter extends ArrayAdapter<JSONObject> { | |
private onGetViewCallback getViewCustomCallBack; | |
public List<JSONObject> objects; | |
private int listViewResourceId; | |
Context context; | |
public CustomJSONListAdapter(Context context, | |
int listViewResourceId, List<JSONObject> objects) { | |
super(context, listViewResourceId, objects); | |
this.listViewResourceId = listViewResourceId; | |
this.objects = objects; | |
this.context = context; | |
} | |
/* | |
* Callbacks from getView | |
*/ | |
public interface onGetViewCallback { | |
View getView(final int position, View convertView, | |
ViewGroup parent); | |
} | |
public void setOnGetViewCallback(onGetViewCallback onGetViewCallback) { | |
getViewCustomCallBack = onGetViewCallback; | |
} | |
@Override | |
public int getCount() { | |
return objects.size(); | |
} | |
@Override | |
public JSONObject getItem(int position) { | |
return objects.get(position); | |
} | |
@Override | |
public long getItemId(int position) { | |
return position; | |
} | |
@Override | |
public View getView(final int position, View convertView, ViewGroup parent) { | |
if(convertView==null) { | |
convertView=(LayoutInflater.from(context)).inflate( listViewResourceId, parent, false); | |
} | |
return getViewCustomCallBack.getView(position, convertView, parent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment