How can I use if statement of a spinner when the selected value = 0?
if( wilayat.setSelection(0) || city.setSelection(0) ||
station.setSelection(0) || distnation.setSelection(0)) {
message = "Select the 4 fields, please..";
Toast.makeText(BusArrivalTime.this, message, Toast.LENGTH_SHORT).show();
}
Try this.
if (wilayat.getSelectedItemPosition() == 0 || city.getSelectedItemPosition() == 0 || station.getSelectedItemPosition() == 0 || distnation.getSelectedItemPosition() == 0) {
message = "Select the 4 fields, please..";
Toast.makeText(BusArrivalTime.this, message, Toast.LENGTH_SHORT).show();
}
Just use getSelectedItemPosition() method.
You make sure that wilayat、city and so on were Spinner.
Add judgement
if (wilayat != null || city != null || station != null || distnation != null) {
// do something
}
This is the structure of my 2d array along with the single array
public String[] sList() {
String list[] = { "Asia Medic Family Hospital and Medical Center",
"Adventist University of the Philippine Health Service ",
"Bautista Hospital",
"Catalan Medical Hospital ",
"Catbagan General Hospital",
"Cavite Center for Mental Health",
"Cavite Doctors' Medical Center, Inc",
"Cavite Medical Center",
"Cavite Municipal Hospital",
"Cavite Naval Hospital",
"Contreras Medical Clinic",
"Crisostomo General Hospital",
"DBB Municipal Hospital",
"DLSU-Dr. Rodolfo Poblete Memorial Hospital ",
"De La Salle University Medical Center",
"Del Rosario Hospital" };
return list;
.....
public String[][] sSpecialty() {
String list[][] = {
{"Specialty 1.0", "Specialty1.1", "Specialty1.2" , " " , " " },
{"Specialty 2.0", "Specialty2.1", "Specialty2.2" , " " , " "},
{"Specialty 3.0", "Specialty3.1", "Specialty3.2", "Specialty3.3", " " },
{"Specialty 4.0", "Specialty4.1", "Specialty4.2", "Specialty4.3", "Specialty4.4" },
{"Specialty 5.0", "Specialty5.1", "Specialty5.2", "Specialty5.3", "Specialty5.4" },
{"Specialty 6.0", "Specialty6.1", "Specialty6.2", "Specialty6.3", "Specialty6.4" },
{"Specialty 7.0", "Specialty7.1", "Specialty7.2", "Specialty7.3", "Specialty7.4" },
{"Specialty 8.0", "Specialty8.1", "Specialty8.2", "Specialty8.3", "Specialty8.4" },
{"Specialty 9.0", "Specialty9.1", "Specialty9.2", "Specialty9.3", "Specialty9.4" },
{"Specialty 10.0", "Specialty10.1", "Specialy10.2", "Specialty10.3", "Specialty10.4" },
{"Specialty 11.0", "Specialty11.1", "Specialty11.2", "Specialty11.3", "Specialty11.4" },
{"Specialty 12.0", "Specialty12.1", "Specialty12.2", "Specialty12.3", "Specialty12.4" },
{"Specialty 13.0", "Specialty13.1", "Specialty13.2", "Specialty13.3", "Specialty13.4" },
{"Specialty 14.0", "Specialty14.1", "Specialty14.2", "Specialty14.3", "Specialty14.4" },
{"Specialty 15.0", "Specialty15.1", "Specialty15.2", "Specialty15.3", "Specialty15.4" },
{"Specialty 16.0", "Specialty16.1", "Specialty16.2", "Specialty16.3", "Specialty16.4" }
};
return list;
How can I filter these 2d array, example I have an item here when I select Specialty2.2 the result is Adventist University of the Philippine Health Service ,as you can see they're both in 2nd array list. Im fine filtering single array but encounter problem when I add 2d array.
for (int loop = 0; loop < sList.length; loop++) {
String temp = sTuition[loop];
theTuitionFee = Integer.parseInt(temp);
// ALL filter selected
if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee
&& sSpecialty[loop][loop].equalsIgnoreCase(thisFilter[5])
) {
list.add(sList[loop]);
Im getting ArrayIndexOutofBoundsException in this part " && sSpecialty[loop][loop].equalsIgnoreCase(thisFilter[5]) " any suggestions how can I get rid of this problem.
Here's the full program when I only use single array if you have any other way to add the created 2d array.
public class SchoolListFragmentFilter extends Fragment implements
OnItemClickListener {
NavigationDrawer navi = new NavigationDrawer();
String thisFilter[] = NavigationDrawer.theFilter;
int amountTF = NavigationDrawer.TuitionFee;
PSManilaDB conn = new PSManilaDB();
String sList[] = conn.sList();
String sReg[] = conn.sRegAffil();
String sAdmin[] = conn.sAdmin();
String sType[] = conn.sSize();
String sAmbience[] = conn.sAmbience();
String sTuition[] = conn.sTuitionFee();
int theTuitionFee;
ListView lvList;
ArrayAdapter<String> mAdapter;
ArrayList<String> list = new ArrayList<String>();
ArrayList<Integer> schoolIndex = new ArrayList<Integer>();
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View v = inflater
.inflate(R.layout.layout_school_list, container, false);
lvList = (ListView) v.findViewById(R.id.lvSchools);
for (int loop = 0; loop < sList.length; loop++) {
String temp = sTuition[loop];
theTuitionFee = Integer.parseInt(temp);
// ALL filter selected
if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
// RegAffil
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& thisFilter[1].equalsIgnoreCase("*")
&& thisFilter[3].equalsIgnoreCase("*") && amountTF == 0) {
list.add(sList[loop]);
// Administration
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*") && amountTF == 0) {
list.add(sList[loop]);
// RoomAmbience
} else if (thisFilter[0].equalsIgnoreCase("*")
&& thisFilter[1].equalsIgnoreCase("*")
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
// Tuition Fee
} else if (thisFilter[0].equalsIgnoreCase("*")
&& thisFilter[1].equalsIgnoreCase("*")
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
// regAffil and admin
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*") && amountTF == 0) {
list.add(sList[loop]);
// regAffil and type
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& thisFilter[1].equalsIgnoreCase("*")
&& thisFilter[3].equalsIgnoreCase("*") && amountTF == 0) {
list.add(sList[loop]);
// regaffil and ambience
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& thisFilter[1].equalsIgnoreCase("*")
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
// reg afill and tuition
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& thisFilter[1].equalsIgnoreCase("*")
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
// admin and type
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*") && amountTF == 0) {
list.add(sList[loop]);
// admin and ambience
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
// admin and tuition
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
// type and ambience
} else if (thisFilter[0].equalsIgnoreCase("*")
&& thisFilter[1].equalsIgnoreCase("*")
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
// type and tuition
} else if (thisFilter[0].equalsIgnoreCase("*")
&& thisFilter[1].equalsIgnoreCase("*")
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
// ambience and tuition
} else if (thisFilter[0].equalsIgnoreCase("*")
&& thisFilter[1].equalsIgnoreCase("*")
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*") && amountTF == 0) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& thisFilter[1].equalsIgnoreCase("*")
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& thisFilter[1].equalsIgnoreCase("*")
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& thisFilter[1].equalsIgnoreCase("*")
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (thisFilter[0].equalsIgnoreCase("*")
&& thisFilter[1].equalsIgnoreCase("*")
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (thisFilter[0].equalsIgnoreCase("*")
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF == 0) {
list.add(sList[loop]);
} else if (sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& thisFilter[3].equalsIgnoreCase("*")
&& amountTF >= theTuitionFee) {
list.add(sList[loop]);
}
}
mAdapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, list);
lvList.setAdapter(mAdapter);
lvList.setOnItemClickListener(this);
schoolIndex.clear();
ArrayList<String> finalFilterList = list;
ArrayList<String> finalSchoolsList = new ArrayList<String>(
Arrays.asList(this.sList));
for (int i = 0; i < finalFilterList.size(); i++) {
for (int o = 0; o < finalSchoolsList.size(); o++) {
if (finalFilterList.get(i).equalsIgnoreCase(
finalSchoolsList.get(o))) {
schoolIndex.add(o);
}
}
}
mAdapter = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_list_item_1, list);
lvList.setAdapter(mAdapter);
lvList.setOnItemClickListener(this);
if (list.isEmpty()) {
Toast.makeText(getActivity(), "No Schools Found",
Toast.LENGTH_SHORT).show();
navi.dia.show();
}
return v;
}
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// TODO Auto-generated method stub
int indx = schoolIndex.get(position);
Toast.makeText(getActivity(), list.get(position), Toast.LENGTH_SHORT)
.show();
Intent woahIntent = new Intent("capstone.app.recommender.SCHOOLINFO");
woahIntent.putExtra("key", indx);
startActivity(woahIntent);
}
// && sAdmin[count].equals(thisFilter[1])
// && sType[count].equals(thisFilter[2]))
}
If I understand correctly, sList.length is 16, but your 2d array width is only 5. This means that loop goes up to 16, but the second index in sSpecialty[loop][loop] must be less than 5. This is where you get the IndexOutOfBoundsException.
I presume you need to replace the if statement with something like
// ALL filter selected
boolean filtermatch=false;
for(int subloop=0;subloop<sSpecialty[loop].length;subloop++){
if (sSpecialty[loop][subloop].equalsIgnoreCase(thisFilter[5])
) {
filtermatch=true;
}
}
if(filtermatch && sReg[loop].equalsIgnoreCase(thisFilter[0])
&& sAdmin[loop].equalsIgnoreCase(thisFilter[1])
&& sAmbience[loop].equalsIgnoreCase(thisFilter[3])
&& amountTF >= theTuitionFee;){
list.add(sList[loop]);
}
The second loop keeps the second index within bounds.
I have a list of numbers, in that list I want to check if any of the numbers match, and if so return 'true'. Essentially, what I want to check is if the numbers match, then do not save. I've gotten a seemingly very inefficient method to check. Any help would be appreciated, thanks!
if (mFav1Compare == mNumber1Compare || mFav1Compare == mNumber2Compare || mFav1Compare == mNumber3Compare || mFav1Compare == mNumber4Compare || mFav1Compare == mNumber5Compare) {
return true;
}
if (mFav2Compare == mNumber1Compare || mFav2Compare == mNumber2Compare || mFav2Compare == mNumber3Compare || mFav2Compare == mNumber4Compare || mFav2Compare == mNumber5Compare) {
return true;
}
if (mFav3Compare == mNumber1Compare || mFav3Compare == mNumber2Compare || mFav3Compare == mNumber3Compare || mFav3Compare == mNumber4Compare || mFav3Compare == mNumber5Compare) {
return true;
}
if (mFav4Compare == mNumber1Compare || mFav4Compare == mNumber2Compare || mFav4Compare == mNumber3Compare || mFav4Compare == mNumber4Compare || mFav4Compare == mNumber5Compare) {
return true;
}
if (mFav5Compare == mNumber1Compare || mFav5Compare == mNumber2Compare || mFav5Compare == mNumber3Compare || mFav5Compare == mNumber4Compare || mFav5Compare == mNumber5Compare) {
return true;
}
If you have two lists and you want to know if the second list contains at least one element of the first list you could try
public <T> boolean listMatches(List<T> list1, List<T> list2) {
for (T element : list1) {
if (list2.contains(element)) {
return true;
}
}
return false;
}
Do you thought this?
ArrayList<Integer>listNumbers = new ArrayList<>();
listNumbers.add(99);
listNumbers.add(99);
listNumbers.add(11);
listNumbers.add(10);
for(int i = 0; i < listNumbers.size(); i++){
if(!listCheck(listNumbers.get(i))){
//save something
}
}
and this method
private boolean listCheck(int number){
for(int i = 0; i < listNumbers.size(); i++){
if(number == listNumbers.get(i)){
return true;
}
}
return false;
}
I am trying to serialize an android.location.Address object using Simple 2.7.1.
I have tried creating a converter...
public class AddressConverter implements Converter<Address> {
#Override
public Address read(InputNode node) throws Exception {
...
//Not included because this part works!!!!
}
#Override
public void write(OutputNode node, Address addr) throws Exception {
node.setAttribute("Locale", addr.getLocale().toString().replace("_", "-"));
OutputNode child = null;
if (addr.getMaxAddressLineIndex() > 0) {
for (int index = 0; index <= addr.getMaxAddressLineIndex(); index++) {
child = node.getChild("AddressLine");
child.setAttribute("Index", String.valueOf(index));
child.setValue(addr.getAddressLine(index));
}
}
if (addr.getFeatureName() != null && addr.getFeatureName().length() > 0) {
child = node.getChild("FeatureName");
child.setValue(addr.getFeatureName());
child.commit();
}
if (addr.getPremises() != null && addr.getPremises().length() > 0) {
child = node.getChild("Premises");
child.setValue(addr.getPremises());
child.commit();
}
if (addr.getSubThoroughfare() != null && addr.getSubThoroughfare().length() > 0) {
child = node.getChild("SubThoroughfare");
child.setValue(addr.getSubThoroughfare());
child.commit();
}
if (addr.getThoroughfare() != null && addr.getThoroughfare().length() > 0) {
child = node.getChild("Thoroughfare");
child.setValue(addr.getThoroughfare());
child.commit();
}
if (addr.getSubLocality() != null && addr.getSubLocality().length() > 0) {
child = node.getChild("SubLocality");
child.setValue(addr.getSubLocality());
child.commit();
}
if (addr.getLocality() != null && addr.getLocality().length() > 0) {
child = node.getChild("Locality");
child.setValue(addr.getLocality());
child.commit();
}
if (addr.getSubAdminArea() != null && addr.getSubAdminArea().length() > 0) {
child = node.getChild("SubAdminArea");
child.setValue(addr.getSubAdminArea());
child.commit();
}
if (addr.getAdminArea() != null && addr.getAdminArea().length() > 0) {
child = node.getChild("AdminArea");
child.setValue(addr.getAdminArea());
child.commit();
}
if (addr.getPostalCode() != null && addr.getPostalCode().length() > 0) {
child = node.getChild("PostalCode");
child.setValue(addr.getPostalCode());
child.commit();
}
if (addr.getCountryCode() != null && addr.getCountryCode().length() > 0) {
child = node.getChild("CountryCode");
child.setValue(addr.getCountryCode());
child.commit();
}
if (addr.getCountryName() != null && addr.getCountryName().length() > 0) {
child = node.getChild("CountryName");
child.setValue(addr.getCountryName());
child.commit();
}
if (addr.getLatitude() != 0) {
child = node.getChild("Latitude");
child.setValue(String.valueOf(addr.getLatitude()));
child.commit();
}
if (addr.getLongitude() != 0) {
child = node.getChild("Longitude");
child.setValue(String.valueOf(addr.getLongitude()));
child.commit();
}
if (addr.getPhone() != null && addr.getPhone().length() > 0) {
child = node.getChild("Phone");
child.setValue(addr.getPhone());
child.commit();
}
node.commit();
}
#SuppressLint("DefaultLocale")
private Locale getLocale(String strLocale) {
String[] splits = strLocale.split("-", 3);
switch (splits.length) {
case 3:
return new Locale(splits[0].toLowerCase(), splits[1].toUpperCase(), splits[2].toUpperCase());
case 2:
return new Locale(splits[0].toLowerCase(), splits[1].toUpperCase());
default:
return new Locale(splits[0].toLowerCase());
}
}
}
I cannot get the write to write the child elements.
Can someone please help me?!
Any suggestions on how to create child nodes with an OutputNode would also be greatly appreciated, as you can see I have tried the documentation but I can't figure it out!!!
I have found that this does serialize the android.location.Address object but it changes the order of where the object is put within the XML!!!
I am sorry if anyone has tried to resolve this, and I can only apologise for wasting your time!!!
I was some problem with the if else statement, please its support
if (btn1.getText().toString().equals(myString[6]) &&
(btn1.getText().toString().equals(myString[6]) || (btn1.getText().toString().equals(myString[7]) || (btn1.getText().toString().equals(myString[8]) || (btn1.getText().toString().equals(myString[9]) || (btn1.getText().toString().equals(myString[10]) || (btn1.getText().toString().equals(myString[11]) || (btn1.getText().toString().equals(myString[12]) || (btn1.getText().toString().equals(myString[13]) || (btn1.getText().toString().equals(myString[14]) || (btn1.getText().toString().equals(myString[15])||
(btn2.getText().toString().equals(myString[6]) || (btn2.getText().toString().equals(myString[7]) || (btn2.getText().toString().equals(myString[8]) || (btn2.getText().toString().equals(myString[9]) || (btn2.getText().toString().equals(myString[10]) || (btn2.getText().toString().equals(myString[11]) || (btn2.getText().toString().equals(myString[12]) || (btn2.getText().toString().equals(myString[13]) || (btn2.getText().toString().equals(myString[14]) || (btn2.getText().toString().equals(myString[15])||
(btn3.getText().toString().equals(myString[6]) || (btn3.getText().toString().equals(myString[7]) || (btn3.getText().toString().equals(myString[8]) || (btn3.getText().toString().equals(myString[9]) || (btn3.getText().toString().equals(myString[10]) || (btn3.getText().toString().equals(myString[11]) || (btn3.getText().toString().equals(myString[12]) || (btn3.getText().toString().equals(myString[13]) || (btn3.getText().toString().equals(myString[14]) || (btn3.getText().toString().equals(myString[15])||
(btn4.getText().toString().equals(myString[6]) || (btn4.getText().toString().equals(myString[7]) || (btn4.getText().toString().equals(myString[8]) || (btn4.getText().toString().equals(myString[9]) || (btn4.getText().toString().equals(myString[10]) || (btn4.getText().toString().equals(myString[11]) || (btn4.getText().toString().equals(myString[12]) || (btn4.getText().toString().equals(myString[13]) || (btn4.getText().toString().equals(myString[14]) || (btn4.getText().toString().equals(myString[15])||
(btn5.getText().toString().equals(myString[6]) || (btn5.getText().toString().equals(myString[7]) || (btn5.getText().toString().equals(myString[8]) || (btn5.getText().toString().equals(myString[9]) || (btn5.getText().toString().equals(myString[10]) || (btn5.getText().toString().equals(myString[11]) || (btn5.getText().toString().equals(myString[12]) || (btn5.getText().toString().equals(myString[13]) || (btn5.getText().toString().equals(myString[14]) || (btn5.getText().toString().equals(myString[15])||
(btn01.getText().toString().equals(myString[6]) || (btn01.getText().toString().equals(myString[7]) || (btn01.getText().toString().equals(myString[8]) || (btn01.getText().toString().equals(myString[9]) || (btn01.getText().toString().equals(myString[10]) || (btn01.getText().toString().equals(myString[11]) || (btn01.getText().toString().equals(myString[12]) || (btn01.getText().toString().equals(myString[13]) || (btn01.getText().toString().equals(myString[14]) || (btn01.getText().toString().equals(myString[15])
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
{
Toast.makeText(getBaseContext(), "something wrong", Toast.LENGTH_SHORT).show();
}
else if (btn1.getText().toString() == (btn2.getText().toString())
(btn1.getText().toString() == (btn3.getText().toString())||
(btn1.getText().toString() == (btn4.getText().toString())||
(btn1.getText().toString() == (btn5.getText().toString())||
(btn1.getText().toString() == (btn01.getText().toString())||
(btn2.getText().toString() == (btn3.getText().toString())||
(btn2.getText().toString() == (btn4.getText().toString())||
(btn2.getText().toString() == (btn5.getText().toString())||
(btn2.getText().toString() == (btn01.getText().toString())||
(btn3.getText().toString() == (btn4.getText().toString())||
(btn3.getText().toString() == (btn5.getText().toString())||
(btn3.getText().toString() == (btn01.getText().toString())||
(btn4.getText().toString() == (btn5.getText().toString())||
(btn4.getText().toString() == (btn01.getText().toString())||
(btn5.getText().toString() == (btn01.getText().toString()))))))))))))))))
{
Toast.makeText(getBaseContext(), "something same", Toast.LENGTH_SHORT).show();
}
else (btn1.getText().toString().equals(myString[0])||
(btn1.getText().toString().equals(myString[1])||(btn1.getText().toString().equals(myString[2])||(btn1.getText().toString().equals(myString[3])||(btn1.getText().toString().equals(myString[4])||(btn1.getText().toString().equals(myString[5])))))))
{
Toast.makeText(getBaseContext(), "test", Toast.LENGTH_SHORT).show();
}
}
if the statement is executed that appear only "something same". what should I add from the code above?
first.... else if (btn1.getText().toString() == (btn2.getText().toString())....
Use .equals() to compare String..and use else if ledder instead of one else if then you can check some problems...