I've been working on this error for too many hours now. The frustrating thing is that the code doesn't have any errors, but when I'm trying to launch the application it doesn't work. And when I delete the code I'm working on, the application runs perfect..
Is there anything missing in the code? Do I have any unnecessary code?
I'm very thankful for any help!
This is my code:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
public class FörstängningFragment extends Fragment {
int checkOne = '0';
int checkTwo = '0';
int checkThree = '0';
ImageView bild = (ImageView)
getView().findViewById(R.id.forstangningimage);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_forstangning, container, false);
bild = (ImageView) rootView.findViewById(R.id.forstangningimage);
bild.setImageResource(R.drawable.forstangning);
CheckBox c = (CheckBox) rootView.findViewById(R.id.checkboxbak);
CheckBox c2 = (CheckBox) rootView.findViewById(R.id.checkBox2);
CheckBox c3 = (CheckBox) rootView.findViewById(R.id.checkBox3);
c.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = ((CheckBox) v).isChecked();
switch (v.getId()) {
case R.id.checkboxbak:
if (checked) {
checkOne = '1';
bild.setImageResource(R.drawable.ic_launcher);
} else {
checkOne = '0';
bild.setImageResource(R.drawable.forstangning);
}
break;
}
onClick(v);
}
});
c2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = ((CheckBox) v).isChecked();
switch (v.getId()) {
case R.id.checkBox2:
if (checked) {
checkTwo = '1';
bild.setImageResource(R.drawable.ic_launcher);
} else {
checkTwo = '0';
bild.setImageResource(R.drawable.forstangning);
}
break;
}
onClick(v);
}
});
c3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = ((CheckBox) v).isChecked();
switch (v.getId()) {
case R.id.checkBox3:
if (checked) {
checkThree = '1';
bild.setImageResource(R.drawable.ic_launcher);
} else {
checkThree = '0';
bild.setImageResource(R.drawable.forstangning);
}
break;
}
onClick(v);
}
});
return rootView;
}
}
Aucun commentaire:
Enregistrer un commentaire