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
Related
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.
Please see attached screeshot. i want to set label dynamically for X axis. Currently is says Test1,Test2,Test3,Test4..if i want to set a category array dynamically how can i do that? i mean i want to set category like House Expense,Office Rent, Food...etc. Here is screenshot and code.
http://www.screencast.com/t/lak24QQvfM3
Here is the bar chart code. see line between 86-90.
http://pastebin.com/MXq4zTbw
Can anyone help me with that? If anything is not clear please ask.
Thanks in advance.
Replace your createDataset() with something like this:
private static CategoryDataset createDataset() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(40.0,"Expediture","House");
dataset.addValue(30.0,"Expediture","Office Rent");
dataset.addValue(-20.5,"Expediture","Food");
dataset.addValue(30.0,"Expediture","Other");
dataset.addValue(6.0,"Expediture","Etc");
return dataset;
}
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
I'm having an arrayList with loads of numbers, I want
to have a different image on every number in the array represented by each number... but I dont know how to put a Variable in (R.drawable."HERE"), if its even possible?!
This is what i've tried to do, Im pretty new to android and Java,
so this may seem pretty funny to you haha... (the array is not shown)
String s = names[position];
String img = s.toString();
holder.imageView.setImageResource(R.drawable.img);
Hope you understand my question.
Thanks in advance
//Halle
You can use reflection do do that. See here for an example.
For a project we use the feed framework libs-for-android. The demo is very good but we can't find out how to grab the link elements in the feed. We try
private static final String[] PROJECTION = {
Entries._ID, Entries.TITLE_PLAINTEXT, Entries.SUMMARY, Entries.CONTENT,
Entries.ALTERNATE_HREF, Links.HREF
};
but Links.HREF is null. Does anyone have a suggestion? The xml can you find here (Atom feed)
Short answer: Does Entries.ALTERNATE_HREF contain the value you're looking for?
Long answer: The columns in the projection must all come from a single table (in this case, Entries). Cursors are flat, so to access nested elements the caller must either perform a second query, or pack child elements into a string or blob column. Another option is to define a column like ALTERNATE_HREF, which is basically just shorthand for the href attribute of the first rel="alternate" link element. There are a couple more columns like this defined in AtomContract, including Entries.ENCLOSURE_HREF and Entries.RELATED_HREF, but you might need to write your own AtomContract and AtomContentHandler if the data you need is not exposed.
The answer is the "short answer". I write my own AtomContract and now the link is stored in Entries.ALTERNATE_HREF
Thanks libs-for-android!