A basically question-> because i cant find a answer since a lot of days...
if i have a for loop
(10 times) and each output is a different string
. How can i make a specific String-output
colored?
for(int i=0; i< posts.length();i++ ) {
JSONObject post = posts.optJSONObject(i);
this.title = post.optString("title");
blogTitles[i] = title;
}
Sure i can sort the specific blogtitles[i]
by code
title.toLowerCase().contains("neune")
but if i try to give it the new layout
, he layout
is used for all (10x) outputs
any can help?
Thx for answer now i changed to
JSONObject post = posts.getJSONObject(i);
this.title = post.getString("title");
but still all outputs are black and in layout "android.R.layout.simple_list_item_1"
complete code
for(int i=0; i< posts.length();i++ ) {
JSONObject post = posts.getJSONObject(i);
this.title = post.getString("title");
arrayAdapter1 = new ArrayAdapter(MainActivity.this, R.layout.mytextview, blogTitles1);
arrayAdapter2 = new ArrayAdapter(MainActivity.this, android.R.layout.simple_list_item_1, blogTitles2);
if (title.toLowerCase().contains("neune") && title.contains(this.id.toLowerCase())) { //ean nicht neu (!kontrolliert!)
// listView.setTheme(R.layout.mytextview);
listView.setAdapter(arrayAdapter1);
String title2= title.replace("neune*", "");
String title3 = title2.replace(this.id + ",", "-eigene Bewertung");
blogTitles1[i] = title3;
bewertungseingabe.setVisibility(View.VISIBLE);
bewertungsueberschrift.setVisibility(View.VISIBLE);
bewertbutton.setVisibility(View.VISIBLE);
editBtn.setVisibility(View.VISIBLE);
}
if (title.toLowerCase().contains("neune") ) {
listView.setAdapter(arrayAdapter2);
String title2= title.replace("neune*", "error!!!!");
String title3 = title2.replace(this.id + ",", "*");
blogTitles2[i] = title3;
}
if (title.toLowerCase().contains("neuja")&& title.contains(this.id.toLowerCase())) { //ean neu (!noch nicht kontrolliert!)
String title2= title.replace("neuja*", "");
String title3 = title2.replace(this.id + ",", "-eigene Bewertung");
blogTitles1[i] = title3;
}
if (title.toLowerCase().contains("neuja") ) {
blogTitles2[i] = "Dieser Artikel ist in Ordnung!";
}
if (title.toLowerCase().contains("ganz")) { //ean neu (!noch nicht kontrolliert!)
blogTitles2[i] = "Du hast uns so eben eine neue EAN mitgeteilt" +
"füge eine Bezeichnung und Bewertung hinzu, wenn du magst...";
// zaehler[i]=blogTitles[i];
}
}
only the second layout is used.... i guess it is because "title.toLowerCase().contains("neune") && title.contains(this.id.toLowerCase())" is true and "title.toLowerCase().contains("neune")" is true.... it "must" be this way, because each (i)output should be evaluated