Reputation:
In my application I should get some list
from server and I should show this list.
code :
private String[] mostlyMatchedKeywordsStrings;
mostlyMatchedKeywordsStrings = searchResponse.getData().getMostlyMatchedKeywordsText();
cloudChipList.clear();
fullSearchMini_chipCloud.removeAllViews();
for (int i = 0; i < mostlyMatchedKeywordsStrings.length; i++) {
cloudChipList.add(mostlyMatchedKeywordsStrings[i]);
if (i >= mostlyMatchedKeywordsStrings.length - 2) {
fullSearchMini_didYouMeanLay.setVisibility(View.VISIBLE);
fullSearchMini_chipCloud.addChip(mostlyMatchedKeywordsStrings[i]);
Log.e("searchKeys", mostlyMatchedKeywordsStrings[i]);
fullSearchMini_chipCloud.setChipListener(new ChipListener() {
@Override
public void chipSelected(int i) {
try {
Log.e("searchKeys", "new : " + mostlyMatchedKeywordsStrings[i]);
}
catch (Exception e) {
}
}
@Override
public void chipDeselected(int i) {
}
});
}
}
When show this data to user it's correct and show data, but when click on this item show me another item!
In Logcat show me below item :
searchKeys: Recep Ivedik 5
But when click on this item show me another item in logcat :
searchKeys: new : Recep Ivedik 3
For show item and click I use this code mostlyMatchedKeywordsStrings[i]
, why in logCat show me another item when click on this item?!
Upvotes: 0
Views: 75
Reputation: 16409
Try this:
Move the following line inside if block:
cloudChipList.add(mostlyMatchedKeywordsStrings[i]);
Then in the method onChipSelected()
use:
Log.e("searchKeys", "new : " + cloudChipList.get(i));
Upvotes: 1