Colorer certains éléments d'une array adapter
Bonjour a tous, voilà j'ai actuellement un bouton qui me permet de lire un fichier XLS et le me l'afficher dans un popups avec le code suivent:
Code:
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
| private boolean LireFichier(Context context, String fileName) {
///Alletre dialogue OK
AlertDialog.Builder builderSingle = new AlertDialog.Builder(Inter.this);
builderSingle.setIcon(R.drawable.ordre);
builderSingle.setTitle("Ordre envoyer jusqu'à présent");
///////////////////////////////////////////////////////
// Lecture du fichier
/////////////////Variable
final int mois = d.getMonth() + 1;
final int annees = d.getYear() - 100;
final int jours = d.getDate();
final String datesok = jours + "." + mois + "." + annees;
// check if available and not read only
if (!isExternalStorageAvailable() || isExternalStorageReadOnly()) {
Log.w("FileUtils", "Storage not available or read only");
return false;
}
boolean success = false;
//New Workbook
// Create a path where we will place our List of objects on external storage
// File file = new File(context.getExternalFilesDir(null), fileName);
FileOutputStream os = null;
FileInputStream file = null;
try {
file = new FileInputStream(new File(context.getExternalFilesDir(null), fileName));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
HSSFWorkbook wb = null;
try {
wb = new HSSFWorkbook(file);
} catch (IOException e) {
e.printStackTrace();
}
// Workbook wb = new HSSFWorkbook();
Cell c = null;
//New Sheet
HSSFSheet sheet1 = wb.getSheetAt(0);
// Generate column headings
int rownum = sheet1.getLastRowNum()+1;
//////////////////////////////
//Update the value of cell
// Row row = sheet1.getRow(0);
// row.createCell(3).setCellValue("Value 2");
/////////////////////////////////
Row row = sheet1.createRow(rownum);
//Row row1 = sheet1.createRow(1);
////////////////////////////////////////////////A faire Ici
///Conteur du nombre de cell
int counter =0;
//String Cellule(counter);
Iterator<Row> rowIter = sheet1.rowIterator();
ArrayList<String> ArrayFichier=new ArrayList<String>();
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ArrayFichier);
// liste.setAdapter(adapter);
///////Fin de la créatuon de la listeview
while (rowIter.hasNext()) {
ArrayList<String> ArrayLigne=new ArrayList<String>();
//Création de la row
HSSFRow myRow = (HSSFRow) rowIter.next();
//HSSFRow test =(HSSFRow) rowIter.next()+1;
Iterator<Cell> cellIter = myRow.cellIterator();
while (cellIter.hasNext()) {
HSSFCell myCell = (HSSFCell) cellIter.next();
Log.w("FileUtils", "Cell Value: " + myCell.toString());
//////////////////////ajouter les 4 premiere cellule dans la ligne
if(counter < 4){
ArrayLigne.add (String.valueOf(myCell));
counter++;
}else{
//Compter les 11 autre et ne rien faire avec
if(counter < 11){
counter++;
}else{
ArrayFichier.add (String.valueOf(ArrayLigne));
counter =0;
}
}
}
}
////////////////////////////////////////////////
//Affichage du popup
builderSingle.setNegativeButton(
"fermer",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builderSingle.setAdapter(
(ListAdapter) adapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String strName = adapter.getItem(which);
AlertDialog.Builder builderInner = new AlertDialog.Builder(
Inter.this);
}
});
builderSingle.show();
return success;
} |
tous ceci fonctionne très bien mais maintenant je voudrait savoir si il est possible de colorer le texte afficher d'une ou plusieurs ligne défini avec couleur spécifique... est ce que dans l'arrayadaper il y a une option comme ceci?
Merci d'avance pour votre aide!