Last active
August 29, 2015 14:13
-
-
Save brunoskonrad/59b5c65798d3271befdb to your computer and use it in GitHub Desktop.
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
public class Entidade { | |
private long mId; | |
private String mNome; | |
public long getId() { | |
return mId; | |
} | |
public String getNome() { | |
return mNome; | |
} | |
public void setNome(String nome) { | |
this.mNome = nome; | |
} | |
@Override | |
public String toString() { | |
return mNome; | |
} | |
} |
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
public class EntidadeAdapter extends BaseAdapter { | |
private Context mContext; | |
private List<Entidade> mEntidades; | |
public EntidadeAdapter(Context context, List<Entidade> entidades) { | |
this.mContext = context; | |
this.mEntidades = entidades; | |
this.mEntidades.add(new EntidadeNullable()); | |
} | |
@Override | |
public int getCount() { | |
return this.mEntidades.size(); | |
} | |
@Override | |
public Object getItem(int i) { | |
return this.mEntidades.get(i); | |
} | |
@Override | |
public long getItemId(int i) { | |
return this.mEntidades.get(i).getId(); | |
} | |
@Override | |
public View getView(int i, View view, ViewGroup viewGroup) { | |
TextView textView = new TextView(this.mContext); | |
Entidade entidade = (Entidade) getItem(i); | |
textView.setText(entidade.toString()); | |
return textView; | |
} | |
} |
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
public class EntidadeNullable extends Entidade { | |
@Override | |
public long getId() { | |
return 0l; | |
} | |
@Override | |
public String toString() { | |
return "Nenhum..."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment