Getting constant false value from method - java

I have 3 questions
private static int NUMBER_OF_QUESTIONS = 3;
static boolean[] answer = new boolean[NUMBER_OF_QUESTIONS];
static boolean[] checked = new boolean[NUMBER_OF_QUESTIONS];
static boolean[] isAnswered = new boolean[NUMBER_OF_QUESTIONS];
and when NOT all questions are answered I have a method
private boolean allAnswersChecked() {
for (boolean radioAnswer : isAnswered) {
if (!radioAnswer) {
return false;
}
}
return true
to show text "You haven't checked all answers"
The problem is that somehow it returns only false even when all rbs are pressed. Another words text "You haven't checked all answers" is still displayed even when all rbs are already checked.
How to change the above method?
OR MAYBE
it happens coz the values in this line
static boolean[] isAnswered = new boolean[NUMBER_OF_QUESTIONS];
don't change AT ALL. Maybe some extra code must be added to method setOnCheckedChangeListener which so far checks only if answers are correct or not.
Here is my code for rb [0]
rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.radioButton1) {
Toast.makeText(getActivity(), "True", Toast.LENGTH_SHORT).show();
checked[0] = true;
answer[0] = true;
} else {
checked[0] = true;
answer[0] = false;
}
}
});

Where are you updating isAnswered array. In the code snippet you have provided, it updates only answer and checked arrays.
Probably that is why you are always getting false for all 3 array elements of isAnswered array.
Where are you updating isAnswered array. In the code snippet you have provided, it updates only answer and checked arrays.
Probably that is why you are always getting false for all 3 array elements of isAnswered array.
Hi Roman,
I believe you have multiple radio groups each with 3 radio buttons. If that is the case, just slight modification in you above code snippet should work for you.
rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.radioButton1) {
Toast.makeText(getActivity(), "True", Toast.LENGTH_SHORT).show();
checked[0] = true;
answer[0] = true;
} else {
checked[0] = true;
answer[0] = false;
}
// update isAnswered[0] to true. as this gets invoked when you choose any radio button.
isAnswered[0] = true;
}
});
Please let me know if this helps.

Try this:
static boolean[] isAnswered = new boolean[NUMBER_OF_QUESTIONS]; // initially all false
.............
....................
rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == R.id.radioButton1) {
Toast.makeText(getActivity(), "True", Toast.LENGTH_SHORT).show();
checked[0] = true;
answer[0] = true;
} else {
checked[0] = true;
answer[0] = false;
}
// Update value as user selected radio button
isAnswered[0] = true;
}
});
Do same for your other RadioGroups(rg2, rg3, ......). Hope this will help~

I have implemented a quick class to validate your logic and found no problems in your implementation.
public class MainActivity extends AppCompatActivity {
private static int NUMBER_OF_QUESTIONS = 3;
static boolean[] isAnswered = new boolean[NUMBER_OF_QUESTIONS];
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setBooleanValues();
allAnswersChecked();
}
private void setBooleanValues() {
isAnswered[0]=true;
isAnswered[1]=false;
isAnswered[2]=true;
}
private void allAnswersChecked() {
for (boolean radioAnswer : isAnswered) {
if (!radioAnswer) {
//return false;
Log.d("allAnswersChecked","false");
}
else {
Log.d("allAnswersChecked","true");
}
}
//return true;
}
}
See the log output :
05-12 16:43:10.299 8448-8448/com.example.myapplicationtest D/allAnswersChecked: true
05-12 16:43:10.299 8448-8448/com.example.myapplicationtest D/allAnswersChecked: false
05-12 16:43:10.299 8448-8448/com.example.myapplicationtest D/allAnswersChecked: true
So I recomment to print values and check if it is being correct set into your isAnswered array before calling allAnswersChecked().

Related

android Get Dynamically checkbox value

Hello I'm a student and My project is making a application by android studio.
I'm just a beginner so everything is difficult :(
Here is my problem.
I dynamically created checkbox depending on the current.
I want to get finalMemberTag if user click the btnEx button.
But In this code, When I click the btnEx, finalMemberTag is null.
And I want that If user click the checkbox, add the checkbox's text to the finalMemberTag.
and checkbox is unchecked, remove the checkbox's text to the finalMemberTag.
How can I do these?
(I already set the drawable things.)
Please Help me...
private String[] finalMemberTag;
Button btnEx;
btnEx.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
sendData();
}
});
Switch(current){
case "A":
String[] memberA = {"all", "ab", "cd", "ef", "g", "hu", "hi", "dd"};
for (int i = 0; i < 8; i++) {
CheckBox chA = new CheckBox(getApplicationContext());
chA.setText(membersA[i]);
chA.setTypeface(ResourcesCompat.getFont(getApplicationContext(), R.font.nanumsquareround_r));
chA.setTextColor(Color.parseColor("#8D8D8D"));
cHA.setButtonDrawable(android.R.color.transparent);
chA.setBackground(inactiveCb);
int index = i;
chA.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
activeCb.setColorFilter(new PorterDuffColorFilter(starColor, PorterDuff.Mode.SRC_IN));
chA.setBackground(activeCb);
chA.setTextColor(startextColor);
finalMemberTag[index] = buttonView.getText().toString();
}
if(!isChecked) {
chA.setBackground(inactiveCb);
chA.setTextColor(Color.parseColor("#8D8D8D")); }
}
});
chA.setPadding(36, 24, 36, 24);
chA.setLayoutParams(params);
placeInputMember.addView(chA);
}
break;
case "B":
String[] memberB = {"all", "abc", "Dcd", "e3f", "DSg", "DGu", "hE", "dV"};
for (int i = 0; i < 8; i++) {
CheckBox chB = new CheckBox(getApplicationContext());
chB.setText(memberB[i]);
chB.setTypeface(ResourcesCompat.getFont(getApplicationContext(), R.font.nanumsquareround_r));
chB.setTextColor(Color.parseColor("#8D8D8D"));
chB.setButtonDrawable(android.R.color.transparent);
chB.setBackground(inactiveCb);
int index = i;
chB.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
activeCb.setColorFilter(new PorterDuffColorFilter(starColor, PorterDuff.Mode.SRC_IN));
chB.setBackground(activeCb);
chB.setTextColor(startextColor);
finalMemberTag[index] = buttonView.getText().toString();
}
if(!isChecked) {
chB.setBackground(inactiveCb);
chB.setTextColor(Color.parseColor("#8D8D8D")); }
}
});
chB.setPadding(36, 24, 36, 24);
chB.setLayoutParams(params);
placeInputMember.addView(chB);
}
break;
}
public void sendData(){
Log.d("##", String.valueOf(finalMemberTag));
}
ANOTHER ERROR
String[] membersA = {"all", "ji", "ha", "bo", "re", "co", "zo", "pi"};
arrayMember = new ArrayList<>();
for (int i = 0; i < membersBts.length; i++) {
CheckBox chA = new CheckBox(getApplicationContext());
chA .setText(members[i]);
chA.setTypeface(ResourcesCompat.getFont(getApplicationContext(), R.font.nanumsquareround_r));
chA.setTextColor(Color.parseColor("#8D8D8D"));
chA .setButtonDrawable(android.R.color.transparent);
chA.setBackground(inactiveCb);
int index = i;
chA.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
activeCb.setColorFilter(new PorterDuffColorFilter(starColor, PorterDuff.Mode.SRC_IN));
chA.setBackground(activeCb);
chA.setTextColor(startextColor);
arrayMember.add(index, buttonView.getText().toString());
}
if(!isChecked) {
chA.setBackground(inactiveCb);
chA.setTextColor(Color.parseColor("#8D8D8D"));
arrayMember.remove(index);
}
}
});
chA.setPadding(36, 24, 36, 24);
chA.setLayoutParams(params);
placeInputMember.addView(chA);
}
break;
ERROR LOGCAT
java.lang.IndexOutOfBoundsException: Index: 5, Size: 2
Ok, you have some issues with your code:
First, finalMemberTag is always null because you never initialized it. If you want to use a string array and you want to store the text on the checkboxes then we should assume that at most you'll have all of the checkboxes (16) selected. This means you'll want to initialize your array as:
private String[] finalMemberTag = new String[16]
Second, I think you'd be better off using a string set to avoid duplicates, or, if you need the information on a particular index, an arraylist.
With the Set:
private Set<String> finalMembersTag = new HashSet<>(16);
//onCreate...other stuff...for loop
//...setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
final String buttonText = buttonView.getText().toString();
if (isChecked) {
// other stuff ...
finalMembersTag.add(buttonText);
} else {
// other stuff ...
finalMembersTag.remove(buttonText);
}
}
With the ArrayList:
private List<String> finalMembersTag = new ArrayList<>(16);
//onCreate...other stuff...for loop
int index = i;
chA.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
#Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
final String buttonText = buttonView.getText().toString();
if (isChecked) {
// other stuff ...
finalMembersTag.add(buttonText); //this will add the text
} else {
// other stuff ...
finalMembersTag.remove(buttonText); //this will remove the element if found, or if you want an empty string you can do finalMembersTag.add(index, "");
}
}

Issue with edittext in TextWatcher

I am trying to configure a simple form . I have 3 editexts and after a user ends input, i want to show up checked icon if it's valid (and goes to the next field) and error if not and the user can correct.
My main issue is I can only input 1 character and then it shows me or error or checked icon and it goes to the next field.
What do I do wrong?
Here is my code:
public class ConTct extends Activity implements OnClickListener, OnTouchListener{
Button mButton;
EditText mFullName, mEmail, mDialZone, mPhone;
static WebView mWebView;
static ProgressBar mProgressBar;
EditText mBrokerId, mIP, mAreaPhonePrefix, mLastName, mPassWord, mCampaign, mSubCampaign, mCountryID, mCity, mAdress, mIsDemo;
private String inputText;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.contct);
registerViews();
}//oncreate()
private void registerViews(){
mFullName = (EditText) findViewById(R.id.firstName);
mFullName.setOnFocusChangeListener(new OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
if(hasFocus){
//do nothing
}else{
if(!Validation.hasText(mFullName)){
mFullName.setError("You have to input at least 3 characters");
mFullName.requestFocus();
}else{
mFullName.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.llgr, 0);
mFullName.clearFocus();
mEmail.requestFocus();
}
}
}
});
mEmail = (EditText) findViewById(R.id.email);
mEmail.setOnFocusChangeListener(new OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
if(hasFocus){
//do nothing
}else{
if(!Validation.isEmailAddress(mEmail, true)){
mEmail.setError("wrong email");
mEmail.requestFocus();
}else{
mEmail.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.llgr, 0);
mEmail.clearFocus();
mPhone.requestFocus();
}
}
}
});
mPhone = (EditText) findViewById(R.id.phoneNumber);
mPhone.setOnFocusChangeListener(new OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
if(hasFocus){
//do nothing
}else{
if(!Validation.isPhoneNumber(mPhone, true)){
mPhone.setError("wrong email");
mPhone.requestFocus();
}else{
mPhone.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.llgr, 0);
mPhone.clearFocus();
}
}
}
});
mButton = (Button) findViewById(R.id.SubmitRegisterButton);
mButton.setOnClickListener(this);
}
private void submitForm() {
// Submit your form here. your form is valid
Toast.makeText(this, "Submitting form...", Toast.LENGTH_LONG).show();
}
private boolean checkValidation() {
boolean ret = true;
if (!Validation.hasText(mFullName)){
ret = false;
}
if (!Validation.isEmailAddress(mEmail, true)){
ret = false;
}
if (!Validation.isPhoneNumber(mPhone, true)){
ret = false;
}
if (!Validation.hasText(mPhone)){
ret = false;
}
return ret;
}//checkValidation
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if ( checkValidation () ){
submitForm();
Intent i = new Intent(getApplicationContext(), ThanksZuser.class);
startActivity(i);
finish();
//send to our crm
grabURL(myURL);
}else
Toast.makeText(ConTct.this, "Form contains error", Toast.LENGTH_LONG).show();
}
}//ConTct.class
Validation class:
package com.Signals4Trading.push.android;
import java.util.regex.Pattern;
import android.widget.EditText;
public class Validation {
// Regular Expression
// you can change the expression based on your need
private static final String EMAIL_REGEX = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*#[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
// private static final String PHONE_REGEX = "\\d{3}-\\d{7}";
// private static final String PHONE_REGEX = "(\\d{3})-(\\d{3})-(\\d{4})";
private static final String PHONE_REGEX = "([0-9-( )]+)";
// Error Messages
private static final String REQUIRED_MSG = "Invalid name. You have to input at least 3 characters";
private static final String EMAIL_MSG = "Invalid email";
private static final String PHONE_MSG = "Invalid number";
// call this method when you need to check email validation
public static boolean isEmailAddress(EditText editText, boolean required) {
return isValid(editText, EMAIL_REGEX, EMAIL_MSG, required);
}
// call this method when you need to check phone number validation
public static boolean isPhoneNumber(EditText editText, boolean required) {
return isValid(editText, PHONE_REGEX, PHONE_MSG, required);
}
/*
// return true if the input field is valid, based on the parameter passed
public static boolean isValid(EditText editText, String regex, String errMsg, boolean required) {
String text = editText.getText().toString().trim();
// clearing the error, if it was previously set by some other values
editText.setError(null);
// text required and editText is blank, so return false
if ( required && !hasText(editText) ) return false;
// pattern doesn't match so returning false
if (required && !Pattern.matches(regex, text)) {
editText.setError(errMsg);
return false;
};
if ( required && !hasNumber(editText)) return false;
return true;
}
*/
// return true if the input field is valid, based on the parameter passed
public static boolean isValid(EditText editText, String regex, String errMsg, boolean bRequired) {
// text required and editText is blank, so return false
String sText = editText.getText().toString().trim();
// clearing the error, if it was previously set by some other values
editText.setError(null);
if (sText.length() == 0) {
if (bRequired) {
editText.setError("*Field required");
return false;
}
} else {
// filled field
// pattern doesn’t match so returning false
if (!Pattern.matches(regex, sText)) {
editText.setError(errMsg);
return false;
}
}
return true;
}
// check the input field has any text or not
// return true if it contains text otherwise false
public static boolean hasText(EditText editText) {
String text = editText.getText().toString().trim();
editText.setError(null);
// length less that 3 means there is no text
if (text.length() <= 3 && text.length() > 12) {
editText.setError(REQUIRED_MSG);
return false;
}
return true;
}
public static boolean hasNumber(EditText editText) {
String text = editText.getText().toString().trim();
editText.setError(null);
// length less that 6 and more than 11 means not available
if (text.length() <= 6 && text.length() >= 11) {
editText.setError(PHONE_MSG);
return false;
}
return true;
}
}//Validation
My main issue is I can only input 1 character and then it shows me or
error or checked icon and it goes to the next field.
Issue is:
You are calling the validation method in onTextChanged. So its going in hasText method, determines there is less than 3 characters, and shows error. In your case, its better to implement using OnFocusChangeListener
Example:
myEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
#Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
//do nothing
}else {
// validate here and show error if invalid and set focus to this element again using requestFocus.
}
}
});
Hope this helps.

how to know the check box value of a particular row of a listview

hey how can i know that the below checkbox when clicked is from which row of the list.
is there any way of knowing that. Every time yo is returning false which is its default value.
checkBox.setOnClickListener( new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v ;
callBlockOptions callBlockOptions = (callBlockOptions) cb.getTag();
callBlockOptions.setChecked( cb.isChecked() );
String yo;
if(callBlockOptions.getPosition()=="0")
{
callBlockOptions.setAllCalls();
}
if(callBlockOptions.getAllCalls() ==true)
yo="true";
else
yo="false";
Toast.makeText(getContext(), callBlockOptions.getPosition(), Toast.LENGTH_LONG).show();
}
});
}
After seeing your code, one thing you might want to try is setting listeners for the individual children within the ListView. You could do something like this:
ListView listView = (ListView)findViewById(R.id.listView);
int count = listView.getChildCount();
for (int x = 0; x < count; x++)
{
Class<? extends View> c = listView.getChildAt(x).getClass();
if (c == CheckBox.class)
{
CheckBox checkBox = (CheckBox)(listView.getChildAt(x));
checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener(){
#Override
public void onCheckedChanged(CompoundButton compoutButton, boolean isChecked) {
// TODO Auto-generated method stub
callBlockOptions.isChecked = isChecked;
}
});
}
else if (c == TextView.class)
{
TextView textView = (TextView)(listView.getChildAt(x));
textView.setOnEditorActionListener(new OnEditorActionListener(){
#Override
public boolean onEditorAction(TextView tView, int arg1, KeyEvent arg2) {
// TODO Auto-generated method stub
callBlockOptions.name = tView.getText().toString();
return true;
}
});
}
You probably want your other class to be like this:
public class callBlockOptions {
public static String name;
public static Boolean isChecked;
}
Then you can get and set name and isChecked like this:
callBlockOptions.isChecked = false;
Boolean boolVal = callBlockOptions.isChecked;

How to validate to rating bar on Button click in Android?

I want to validation on RatingBar in Android. I have 5 rating Bar and 1 Button. I don't want to submit the data without pressed the rating bar. I want to take validation on Rating bar.
Can someone help me. How to take validation on Rating bar?
Here is my Activity code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.rating_baar);
databaseHelper = new DatabaseHelper(this);
databaseHelper.onOpen(db);
addListenerOnRatingBar_one();
addListenerOnRatingBar_two();
addListenerOnRatingBar_three();
addListenerOnRatingBar_four();
addListenerOnRatingBar_five();
addListenerOnButton();
}
#SuppressLint("SimpleDateFormat")
public void addListenerOnButton() {
buttonSubmitRate = (Button) findViewById(R.id.button_SubmitRate);
buttonSubmitRate.setOnClickListener(new OnClickListener() {
#SuppressLint("SimpleDateFormat")
#Override
public void onClick(View v) {
if((etTaskName.getText().toString().isEmpty()))
etTaskName.setError("Field Can Not Be Empty !");
else if (!etTaskName.getText().toString().trim().matches("[a-zA-Z{ }]+"))
etTaskName.setError("Accept Alphabets Only.");
else {
strEmpName = textViewNAme.getText().toString().trim();
strTaskName = etTaskName.getText().toString().trim();
String strCurrentDate = new SimpleDateFormat("dd/MM/yyyy").format(new Date());
System.out.println("strCurrentDate = " + strCurrentDate);
String strCurrentMonth = new SimpleDateFormat("MMM").format(new Date());
System.out.println("strCurrentDate = " + strCurrentMonth);
String strCurrenYear = new SimpleDateFormat("yyyy").format(new Date());
System.out.println("strCurrenYear = " + strCurrenYear);
System.out.println("__________________________________________________________________________________");
databaseHelper.insertPerformance_Details(intentStr1, strEmpName,
strTaskName, rateVal_one,
rateVal_two, rateVal_three,
rateVal_four,rateVal_five,
strCurrentDate,strCurrentMonth,
strCurrenYear);
System.out.println("Data Add SuccesFully !!!!");
etTaskName.setText("");
Intent i = new Intent(RatingBaar_Class.this, Rating_Msg.class);
startActivity(i);
finish();
overridePendingTransition(R.anim.anim_in,R.anim.anim_out);
}
}
});
}
public void addListenerOnRatingBar_one() {
ratingBar_one = (RatingBar) findViewById(R.id.ratingBar1);
ratingBar_one.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
rateVal_one = String.valueOf(rating);
System.out.println(" rateVal_one = " + rateVal_one);
}
});
}
/* Exactly the same methods for four other rating bars, except for variable names */
public void addListenerOnRatingBar_two() { ... }
public void addListenerOnRatingBar_three() { ... }
public void addListenerOnRatingBar_four() { ... }
public void addListenerOnRatingBar_five() { ... }
At first set all rating bar to 0 value. Then on click to button, check if the value has altered in all of them. If so, only valid else invalid.
Also you can use listener to each rating bar and change value of some boolean variable to true
Example:
boolean flag1 = false;
boolean flag2 = false;
.... //similarly upto 5
Then in rating bar listener1
{
flag1 = true;
}
Similarly for all set flag to be true
And in button onClickListener do the following:
if(flag1 && flag2 && flag3 && flag4 && flag5){
//do your work
}else{
//display message that one of the rating bar hasn't been touched
}

ListView Checkbox list not registering checks

I have a ListView with a list of checkable elements. Multiple elements can be checked. I did this to try to check which boxes were ticked:
#SuppressLint("ShowToast")
public class ListOfMajors extends Activity {
public static boolean aerospace, agricultural, biomed, chem, civil, computer, electrical, physics, environment, industrial, materials, mechanical;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.majorslist);
ListView mylist = (ListView) findViewById(R.id.majorslist);
String[] list={"Aerospace Engineering","Agricultural Engineering","Biomedical Engineering","Chemical Engineering","Civil Engineering",
"Computer Engineering","Electrical Engineering","Engineering Physics","Environmental Engineering","Industrial Engineering",
"Materials Engineering","Mechanical Engineering"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(ListOfMajors.this,android.R.layout.simple_list_item_multiple_choice,list);
mylist.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
mylist.setAdapter(adapter);
SparseBooleanArray checkedItems = mylist.getCheckedItemPositions();
if (checkedItems!= null){
for(int i=0; i<checkedItems.size();i++){
if(checkedItems.valueAt(0)){
aerospace = true;
}
if(checkedItems.valueAt(1)){
agricultural = true;
}
if(checkedItems.valueAt(2)){
biomed = true;
}
if(checkedItems.valueAt(3)){
chem = true;
}
if(checkedItems.valueAt(4)){
civil = true;
}
if(checkedItems.valueAt(5)){
computer = true;
}
if(checkedItems.valueAt(6)){
electrical = true;
}
if(checkedItems.valueAt(7)){
physics = true;
}
if(checkedItems.valueAt(8)){
environment = true;
}
if(checkedItems.valueAt(9)){
industrial = true;
}
if(checkedItems.valueAt(10)){
materials = true;
}
if(checkedItems.valueAt(11)){
mechanical = true;
}
}
}
}
}
Is this code the correct way to accomplish this? My application is not doing what I intended to do elsewhere in the application and was wondering whether this would be the problem. If so, how should I fix it?
It looks like you do not have an OnItemClickListener
mylist.setOnItemClickListener(this);
#Override
public void onItemClick(AdapterView<?> adapter, View arg1, int pos, long arg3)
{
switch (pos){
case 0:
aerospace = true;
break;
case 1:
agricultural = true;
break;
......etc
}
}

Categories

Resources