Basically my android activity displays a Pizza with 4 different toppings represented by 4 imageview over one another and having their visibility set to gone. There are 4 checkboxes that when checked displays the respective imageview by setting it to visible. However the app crashes on the emulator everytime and only when I reduce the imageview to 2 did the activity runs smoothly. I managed to create 3 imageview without crashing but the all the imageview are of low quality and the app has very noticeable lag. So how do you create an app such as mine that displays multiple imageview over one another without forsaking image quality for the sake of saving memory and having lag?
Here's my code:
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CheckBox extracheese = (CheckBox) findViewById(R.id.checkBox1);
CheckBox pineapple = (CheckBox) findViewById(R.id.checkBox2);
CheckBox chicken = (CheckBox) findViewById(R.id.checkBox3);
CheckBox seafood = (CheckBox) findViewById(R.id.checkBox4);
extracheese.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
ImageView extracheesee = (ImageView)findViewById(R.id.imageView2);
if(((CheckBox) v).isChecked()){
extracheesee.setVisibility(View.VISIBLE);
}else{
extracheesee.setVisibility(View.GONE);
}
}
});
pineapple.setOnClickListener(new OnClickListener() {
public void onClick(View vi) {
ImageView extracheeseee = (ImageView)findViewById(R.id.imageView2);
if(((CheckBox) vi).isChecked()){
extracheeseee.setVisibility(View.VISIBLE);
}else{
extracheeseee.setVisibility(View.GONE);
}
}
});
chicken.setOnClickListener(new OnClickListener() {
public void onClick(View vi) {
ImageView extracheeseee = (ImageView)findViewById(R.id.imageView3);
if(((CheckBox) vi).isChecked()){
extracheeseee.setVisibility(View.VISIBLE);
}else{
extracheeseee.setVisibility(View.GONE);
}
}
});
}
}