I'm a newbie to programming. I have gone through all the related links regarding this question. So it is a request to not mark it as duplicate question. It is a different question and might be possible can help others too.
There are some house holds Refer Image 1. If a family of one house hold is migrated, it will have a value in a "Family_Migration" column in the Database otherwise "NULL" Refer Image 2. So the scenario is there are families living in multiple house holds as discussed above (some are migrated and some are still resident). Those House Holds who are migrated I want their Background color programmatically to be changed like this Refer Image 3
I'm sharing my adapter code with you. I have already set the getter/setter and I also debugged it in depth and I'm receiving value in getter, but here I'm stuck now, all I want to know how to accomplish the above scenario? As far as I know there must be a usage of IF condition and inside IF condition we put the data that we are receiving from the database. But how?
It is preferable and I will be very thankful to you If you can make some changes in the code and share it with me.
package pk.softech.sukh.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.List;
import pk.softech.sukh.R;
import pk.softech.sukh.modal.HouseModal;
public class HouseAdapter extends ArrayAdapter<HouseModal> {
public HouseAdapter(Context context,List<HouseModal> items) {
super(context,R.layout.view_house_item,items);
}
class ViewHolder{
TextView totalAfrad,totalKhandan,structureID;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
ViewHolder holder;
HouseModal item = getItem(position);
if(view == null){
view = LayoutInflater.from(getContext()).inflate(R.layout.view_house_item,null);
holder = new ViewHolder();
holder.structureID = (TextView) view.findViewById(R.id.structureID);
holder.totalAfrad = (TextView) view.findViewById(R.id.totalAfrad);
holder.totalKhandan = (TextView) view.findViewById(R.id.totalKhandan);
view.setTag(holder);
}
else{
holder = (ViewHolder) view.getTag();
}
holder.structureID.setText(String.valueOf(item.getStructureNo()));
holder.totalKhandan.setText(String.valueOf(item.getFamilies()));
holder.totalAfrad.setText(String.valueOf(item.getMembers()));
return view;
}
}