I want to implement a listview were you can search for items and click on them. Here everything works fine. Now I have some items in the view were I want to set the alpha value to make them look like they cant be clicked. To show the problem I reduced my function to just set the alpha value to items were some variable called "rezept_groesse" equals "Snack". This String is also shown on the list view. So my task for now: Reduce the alpha value for items were "rezept_groesse" equals "Snack". Doesnt sound very complicated, but I get some strange behaviour: I created a custom Base Adapter and in "getView" I set the Text of the items (TextViews) an also the alpha value like this:
if(spannableString_groesse.toString().equals("Snack")){
holder.rezept_name_search.setAlpha(0.2f);
}
holder.rezept_name_search.setText(spannableStringBuilder);
But the alpha value isn't set only for the "Snack" values but also for some other ones:
as you can see not only for "Snack" the alpha value is reduced, but also for "kleine Mahlzeit", but not always.
If I scroll the ListView up and down for some times, one after another, the alpha value of all listview items gets reduced, doesn't matter which value "mahlzeit_groesse" has:
Maybe someone has an explanation for this problem? Thanks for any help!
I solved my problem now. My mistake was to not reset the alpha value while scrolling. So after a while the alpha value of every element gets set to 0.2f. The code had to be changed to something like this:`
if(spannableString_groesse.toString().equals("Snack")){
holder.rezept_name_search.setAlpha(0.2f);
}else{
holder.rezept_name_search.setAlpha(1.0f);
}
holder.rezept_name_search.setText(spannableStringBuilder);