1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| public class menu4_Fragment extends Fragment {
View rootview;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootview = inflater.inflate(R.layout.codon, container, false);
ListView listViewAcidAmin = (ListView) rootview.findViewById(R.id.listViewAcidAmin);
ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
map = new HashMap<String, String>();
map.put("Nom", "Alanine");
map.put("Code", "A");
map.put("Abv", "Ala");
map.put("Nature", "Apolaire, aliphatique");
map.put("Codon", "GCU");
map.put("Codon", "GCC");
map.put("Codon", "GCG");
map.put("Codon", "GCA");
map.put("ref","1");
listItem.add(map);
final SimpleAdapter mSchedule = new SimpleAdapter (rootview.getContext(), listItem, R.layout.affichageitems,
new String[] { "Codon"}, new int[] { R.id.type});
listViewAcidAmin.setAdapter(mSchedule);
listViewAcidAmin.setTextFilterEnabled(true);
listViewAcidAmin.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@SuppressWarnings("unchecked")
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
ListView listViewAcidAmin = (ListView) rootview.findViewById(R.id.listViewAcidAmin);
TextView nom = (TextView) rootview.findViewById(R.id.Nom);
TextView code = (TextView) rootview.findViewById(R.id.Code);
TextView abv = (TextView) rootview.findViewById(R.id.Abv);
TextView nat = (TextView) rootview.findViewById(R.id.Nature);
TextView codon = (TextView) rootview.findViewById(R.id.Codon);
TextView ref = (TextView) rootview.findViewById(R.id.ref);
HashMap<String, String> map = (HashMap<String, String>) listViewAcidAmin.getItemAtPosition(position);
nom.setText(map.get("Nom"));
code.setText(map.get("Code"));
abv.setText(map.get("Abv"));
nat.setText(map.get("Nature"));
codon.setText(map.get("Codon"));
ref.setText(map.get("ref"));
}
});
EditText myFilter = (EditText) rootview.findViewById(R.id.search);
myFilter.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
mSchedule.getFilter().filter(s.toString());
}
});
return rootview;
}
} |
Partager