I'm trying to change the TEXT color of this listView I made following some examples on the internet, but the most I got was the comment from the line 39 txt.setTextColor (Color.GREEN); The problem is that this only changes the color when clicked and even then the color does not return to normal. : / I need a solution to make the appearance a little more beautiful, I've tried several tutorials from other websites but they did not work very well.
I would like a solution that is as simple as possible for studies. But anything that works is worth it, too. :)
The Main class:
public class Main extends Activity {
public ListView list;
static int numPerildo = 2;
static String perildoAtual;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, Cursos);
list = (ListView) findViewById(R.id.list);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View view, int position, long id) {
TextView txt = (TextView) view; //funciona
//txt.setTextColor(Color.GREEN);
//TextView txt = (TextView) view.findViewById(R.id.post);
//mensagem.setTitle("Escolha qual o perildo");
//mensagem.setMessage( txt.getText().toString() );
//mensagem.setNeutralButton("OK", null);
//txt.setTextColor(color.white);
//trace("Item selecionado : " + position);
if(txt.getText().toString().equals("valor 1")){
numPerildo = 5;
telaPerildo();
}
perildoAtual = txt.getText().toString();
}
});
}
public void telaPerildo(){
Intent i = new Intent(this, Periodo.class);
startActivity(i);
}
static final String[] Cursos = new String[] {"valor 1",
"valor 2",
"valor 3"};
public void toast (String msg){
Toast.makeText (getApplicationContext(), msg, Toast.LENGTH_SHORT).show ();
}
private void trace (String msg){
toast (msg);
}
}
A Main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/azulClaro"
tools:context="${packageName}.${activityClass}" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Escolha o seu curso:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/text" >
</ListView>
</RelativeLayout>