Reputation: 3219
I have two button and i would like to show one button ''NEW TV SHOW'' if year of tv show is above 2014 and i have successed in that applying this condition:
if (serija.getYear() >= 2014) {
prikaziDugme();
} else {
nePrikazujDugme();
}
but when applying this second condition for other button it's not working:
if (serija.getPremijera() == "premijera"){
prikaziPremijeraDugme();
nePrikazujDugme();
nePrikazujZvezdu();
} else{
nePrikazujDugme();
nePrikazujPremijeraDugme();
}
This second condition say that this button will show only if there is String "premijera"
, but i don't want then to show this first button there and also i wouldn't want to show one ImageView there which is representing rating star. I have set the visibility to this second button in layout gone
and in my method i'm setting the visibility to "visible" and calling that method in this if statement. But something isn't working.
Here is my whole code of adapter where i'm trying to finish this:
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
if (inflater == null)
inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null)
convertView = inflater.inflate(R.layout.tv_show_now_row, null);
if (imageLoader == null)
imageLoader = AppController.getInstance().getImageLoader();
NetworkImageView thumbNail = (NetworkImageView) convertView
.findViewById(R.id.thumbnail);
TextView title = (TextView) convertView.findViewById(R.id.title);
TextView rating = (TextView) convertView.findViewById(R.id.rating);
TextView year = (TextView) convertView.findViewById(R.id.year);
TextView kanal = (TextView) convertView.findViewById(R.id.kanal);
TextView showtime = (TextView) convertView.findViewById(R.id.vreme_prikazivanja_serije);
TextView premijera = (TextView) convertView.findViewById(R.id.premijera);
btn_novo = (Button) convertView.findViewById(R.id.button1);
btn_premijera = (Button) convertView.findViewById(R.id.button2);
rating_star = (ImageView) convertView.findViewById(R.id.rating_star);
// getting tvShow data for the row
Serija serija = tvShowItems.get(position);
// setting the result for images and textviews
thumbNail.setImageUrl(serija.getImage(), imageLoader);
title.setText(serija.getTitle());
rating.setText(serija.getRating());
year.setText(String.valueOf(serija.getYear()));
kanal.setText(serija.getKanal());
showtime.setText(serija.getShowtime());
premijera.setText(serija.getPremijera());
if (serija.getYear() >= 2014) {
prikaziDugme();
} else {
nePrikazujDugme();
}
if (serija.getPremijera() == "premijera"){
prikaziPremijeraDugme();
nePrikazujDugme();
nePrikazujZvezdu();
} else{
nePrikazujDugme();
nePrikazujPremijeraDugme();
}
Animation animation = AnimationUtils.loadAnimation(activity, (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
convertView.startAnimation(animation);
lastPosition = position;
return convertView;
}
private void prikaziDugme() {
btn_novo.setVisibility(View.VISIBLE);
}
private void nePrikazujDugme() {
btn_novo.setVisibility(View.GONE);
}
private void prikaziPremijeraDugme() {
btn_premijera.setVisibility(View.VISIBLE);
}
private void nePrikazujPremijeraDugme() {
btn_premijera.setVisibility(View.GONE);
}
private void nePrikazujZvezdu() {
rating_star.setVisibility(View.GONE);
}
}
I have tried also with cases, but didn't have luck with it.
Upvotes: 0
Views: 27
Reputation: 5251
Instead of using:
if (serija.getPremijera() == "premijera"){
...
..
}
Use this:
if (serija.getPremijera().equals("premijera")){
...
..
}
Upvotes: 3