I have included a Search Dialog in my Activity which works fine. However adding Search Suggestions gives me a little problem: The search suggestion entries are "empty".
I can see my content provider gets called (query(..)) and I return a MatrixCursor with several rows. The suggestions list also shows with (clickable) entries -- but are all blank. Blank as if the string I returned for SUGGEST_COLUMN_TEXT_1 and SUGGEST_COLUMN_TEXT_2 where an empty string.
The columns I use in the MatrixCursor are:
String[] columnNames = {"_ID", "SUGGEST_COLUMN_TEXT_1", "SUGGEST_COLUMN_TEXT_2", "SUGGEST_COLUMN_INTENT_EXTRA_DATA"};
I did try with just the _ID and SUGGEST_COLUMN_TEXT_1 column but same result.
EDIT: And I tried returning a simple "test" string as SUGGEST_COLUMN_TEXT_1 instead of something from my data.
I'm note quite sure what code is relevant here, so please ask for whatever may be needed to figure this out.
I have no idea for where to look for this bug, and my Google-Fu has failed me.
Thanks
(I would like to have added an 'android-search-suggestion' tag, but I'm newguy so it seems I cant)
(Thank you, Jcwenger for teaching the new guy :-)
The solution, from my comment above:
Found it. Use SearchManager.SUGGEST_COLUMN_TEXT_1 instead of "SUGGEST_COLUMN_TEXT_1".. (Same for the rest).The String SearchManager.SUGGEST_COLUMN_TEXT_1 maps to "suggest_text_1": http://developer.android.com/reference/android/app/SearchManager.html#SUGGEST_COLUMN_TEXT_1
Related
Some time ago i tried to use a BaaS service (parse.com), now I want to make a query to fetch a result set where parse' table contained tag values as "tag1, tag2, tag2"
I found similar question, but it doesn't work fo me, in my case I get row where TAG column equals one of tags item, but not contained one of them
query.whereContainedIn("Tags", Arrays.asList("tag1", "tag2"));
If someone had same issue please help me resolve it or give a correct way to figure it out
I am new to Parse and i am working on a Project that uses Android PARSE Sdk so i was wondering on how can i make a where query with or condition using the android sdk.
I want to make a query like this [Psuedo code]
Select * from employ where employId is ("1","2","3")
I found this on parse documentation, i don't know if it helps or not.
Edit:
This is what i found on PARSE but its not working
String[] id= {"1","2","3"};
query.whereContainedIn("employId ", Arrays.asList(id));
It returns me an empty list but if i query them one by one i get result... Can anyone tell me whats wrong ?
You can use whereContainedIn to select specific rows. See this post you can get more ideas. https://www.parse.com/questions/different-arrays-and-wherecontainedin-for-android.
List<String> employId = new ArrayList<String>();
employId.add("1"); employId.add("2"); employId.add("2");
query.whereContainedIn("employId", employId);
If you are still not clear. check this https://www.parse.com/docs/android_guide#queries
I have found the solution and i must say its pretty lame of PARSE to not mention this anywhere in there documentation.
The problem was that the values that i was using inwhereContainedIn method were of type String but in reality they were pointers to another table's row.
I was trying to get the values using only there ids[as it is displayed on parse] but instead i had to pass the whole object in order to retrieve them. That was the reason on why it was returning empty list.
The thing is Even though it displays IDs [pointer to object in a table] we cant search using only ID's instead we have to use complete Parse objects if we want to search a table based on Specific Object.
I know that AlphabetIndexer class in Android uses ASCII ordering to order items in the list. It means that if I have items starting for example with lower case "a" it will be ordered after upper case "Z" which seems not so logical. So is there a way to somehow combine lower and upper case letters in such kind of situations?
A good example of success in this is the contacts list of Viber, they don't only managed to put "Y" and "y" in the same section but also show two letters "Yy" in the SectionIndexer. So is it possible to achieve with default AlphabetIndexer? Has anybody some experience with such kind of problem?
It appeared that the solution of this problem is easier but a little bit tricky.
It seems that the problem is not in AlphabetIndexer itself, but in the way the elements are ordered in the cursor that it gets.
So everything I did to solve this problem is to add a right COLLATE to my SQL query.
So I have added the following as a sort order:
private final String SORT_ORDER = Contacts.DISPLAY_NAME_PRIMARY + " COLLATE LOCALIZED ASC";
Note: Contacts.DISPLAY_NAME_PRIMARY is for API 11+ ... for lower APIs you need Contacts.DISPLAY_NAME .
P.S I think this was the only thing that I did to solve this issue, but I don't remember for sure. If it will not help, please tell me and I will look at my code again.
if you want the ordering to not be case sensitive, you need to create your own extension of AlphabetIndexer and overwrite the Compare function to compare the strings in the same case
I want to customize suggstions
which I get throught suggestion provider. I vant to add there one image to the left and one sub title. it should look like this:
Is that way to change the layout of them? Thanks for all of the answers.
Please put any response of google suggestion api that have images.
Not sure whether that google suggestion responce gives images also or not. If google suggestion API gives images in responce then yes you can do it. But if they not then you can not able to put images.
Yes, you can put any static images and static description that is common for all the suggestion list. But not able to set any dynamic images if the google suggestion not provided.
hope you got the point.
I find it out, it can be done with adding 2 more lines:
private static final String[] SEARCH_SUGGEST_COLUMNS = {
BaseColumns._ID,
SearchManager.SUGGEST_COLUMN_TEXT_1,
SearchManager.SUGGEST_COLUMN_TEXT_2,//this
SearchManager.SUGGEST_COLUMN_ICON_1,//this
SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID
};
and you can add the image simply to cursor like this:
cursor.addRow(new Object[] { -1, "Plants", "Search Plants", R.drawable.pin_bank,0});
hope it helps
I am working on an Android project where I am struck with a issue. I need to fetch data from SQLite db based on condition provided.
In precise I mean to say I need to get the data from SQLite where I provide condition an display that returned value in EditText.
Like:
SELECT SPECIALCHARCTER FROM <TABLENAME> WHERE POSITION = "0";
I need a good link to study this process. Can anyone please help me in issue.
You can check out sample code of DBHelper.java class.
I shall be very happy to see reply from u friends and help me in solving this issue.
Thanks & Regards,
Raghav
Try select statement in the following way
SELECT * FROM Contact where position LIKE '%"+0+"%'"
this may helps you
Sorry but you code pasted is a mess as it is not good formatted and filled with code that is commented out. Hard to see anything.
What I saw was this code:
EditText result=(EditText)findViewById(R.id.input);
Cursor c = db.rawQuery("SELECT SPECIALCHARCTER FROM " + TABLE + " where POSITION = 0", null);
int A = c.getColumnIndex("POSITION");
String strRet;
strRet = c.getString(A);
results.setText("" + strRet);
c.moveToNext();
This will fail for multiple reasons:
Your cursor c is never moved to the first place before you access it. So it will always fail
Calling c.moveToNext() at the end of the method is senseless
Your variable results is never initialized
My advice: Remove every UI element from this class and start reading some links Pratik provided in his answer.
here is the good links to work with the sqlite with android with many controls
http://www.vogella.de/articles/AndroidListView/article.html
http://marakana.com/forums/android/examples/55.html
http://saigeethamn.blogspot.com/2009/10/android-developer-tutorial-part-12.html