Created
March 14, 2012 10:29
-
-
Save Dimillian/2035626 to your computer and use it in GitHub Desktop.
AHA
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 your.testpro; | |
import java.util.ArrayList; | |
import android.content.Context; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.view.ViewGroup.LayoutParams; | |
import android.widget.BaseAdapter; | |
import android.widget.LinearLayout; | |
import android.widget.RelativeLayout; | |
import android.widget.TextView; | |
public class myAdapter extends BaseAdapter { | |
private ArrayList<SerialObject> objets; | |
private Context context; | |
public myAdapter(Context c, ArrayList<SerialObject> objets) { | |
super(); | |
this.objets = objets; | |
this.context = c; | |
} | |
@Override | |
public int getCount() { | |
return objets.size(); | |
} | |
@Override | |
public Object getItem(int arg0) { | |
return objets.get(arg0); | |
} | |
@Override | |
public long getItemId(int position) { | |
return position; | |
} | |
@Override | |
public View getView(int position, View convertView, ViewGroup parent) { | |
SerialObject objet = (SerialObject)getItem(position); | |
RelativeLayout r1; | |
r1 = new RelativeLayout(context); | |
TextView mTitle = new TextView(context); | |
mTitle.setText(objet.getUsername()); | |
mTitle.setHeight(58); | |
r1.addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); | |
return r1; | |
} | |
public void add(SerialObject serialObject) { | |
objets.add(serialObject); | |
} | |
public void delete(int position) { | |
objets.remove(position); | |
} | |
public void edit(int position) { | |
SerialObject objet = objets.get(position); | |
objet.setName("Edited"); | |
objet.setUsername("Editer"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment