I have 1 int and 1 string from intent extras with positions I want to be set image view drawable Exact image from the position from the selected item. codes work and Log show correct position but image view won't show anything in device any ids?
// this is intent from the list item
Intent inspol = new Intent(getActivity(),Item_Click_open.class);
inspol.putExtra("IMAGE_SELECT",datassss[position]);
if (boxcolor1 == 0||boxcolor2 == 0) {
inspol.putExtra("IMAGE_TYPE",1);
}
if (boxcolor1 == 1||boxcolor2 == 1) {
inspol.putExtra("IMAGE_TYPE",2);
}
if (boxcolor1 == 2||boxcolor2 == 2) {
inspol.putExtra("IMAGE_TYPE",3);
}
new Pair<View, String>(view.findViewById(R.id.big_image),
Item_Click_open.VIEW_NAME_HEADER_IMAGE),
new Pair<View, String>(view.findViewById(R.id.big_image),
Item_Click_open.VIEW_NAME_HEADER_IMAGE2));;
ActivityCompat.startActivity(getActivity(),inspol,activityOptions.toBundle());
}
});
// the activity must image view set drawable
Intent ilm = getIntent();
sps = ilm.getStringExtra("IMAGE_SELECT");
popint = ilm.getIntExtra("IMAGE_TYPE",0);
imsec = (ImageView) findViewById(R.id.imseccc);
if (popint == 1) {
if (sps == "Beginner") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_bign));
}
if (sps == "Elementary") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_ele2));
}
if (sps == "Intermediate") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_inter));
}
if (sps == "Advance") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_advice));
}
}
if (popint == 2) {
if (sps == "Beginner") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_chery));
}
if (sps == "Elementary") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_limon));
}
if (sps == "Intermediate") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_sbr));
}
if (sps == "Advance") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_oldfood));
}
}
Thanks for Helping!
Use Java's equals
method in order to compare Strings:
if (sps.equals("Beginner") {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_bign));
}
if (sps.equals("Elementary")) {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_ele2));
}
if (sps.equals("Intermediate")) {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_inter));
}
if (sps.equals("Advance")) {
imsec.setImageDrawable(getResources().getDrawable(R.drawable.ic_tree_advice));
}