J'ai une liste dans laquelle ils sont deux textview et un EditView dans une seule rangée. Je lie ces textviews et editview au moment de l'exécution et maintenant je veux faire une validation pour edittext dans listview, mais mon ID EditView est le même pour toutes les lignes, alors comment puis-je appliquer des validations dans cet editview plz m'aider.comment faire la validation dans Android EditText dans un ListView?
Merci à l'avance et désolé pour mon pauvre anglais
Mon code est ici
try {
json = new JSONObject(status);
getArray_Meter_Reading = new JSONArray();
getArray_Meter_Reading = json.getJSONArray("meterReadings");
myList = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < getArray_Meter_Reading.length(); i++) {
map = new HashMap<String, String>();
String meter_Name = getArray_Meter_Reading.getJSONObject(i)
.getString("MeterName").toString();
String previous_Meter_Reading = getArray_Meter_Reading
.getJSONObject(i).getString("PrevMeterReading")
.toString();
map.put("meterName", meter_Name);
map.put("previousMeterReading", previous_Meter_Reading);
myList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
SimpleAdapter myAdapter = new SimpleAdapter(this, myList,
R.layout.meter_reading_list, new String[] {
"meterName", "previousMeterReading" }, new int[] { R.id.txt_Meter_Name,
R.id.txt_Previous});
lst.setAdapter(myAdapter);
lst.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE){
lst.scrollBy(0, 1);
}
return false;
}
});
et ma mise en page de Xml qui im joli immeuble avec ce listview
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="6dip"
android:paddingTop="4dip" >
<TextView
android:id="@+id/txt_Meter_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:width="140dp" />
<TextView
android:id="@+id/txt_Previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:width="100dp" />
<EditText
android:id="@+id/ed_Current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:imeOptions="actionNext|actionDone"
android:singleLine="true"
android:width="100dp" >
</EditText>
« mais mon ID EditView est identique pour toutes les lignes » ce n'est pas votre problème que seulement quelques EditViews existent, et non pour chaque ligne (uniquement pour ceux qui sont visibles) ... http: // www.youtube.com/watch?v=wDBM6wVEO70 – Selvin