Showing SearchWidget on left and opened on Actionbar(actionbar compat) when activity loads - searchview

I am new to android and working on an app like dictionary.I am using search view from actionbar compat for searching suggestion and it is working good.
The problem is I want the search view on left aligned(where title shows) on actionbar and opened when the activity loads which is ok with normal devices but on tab it looks right aligned.
I have tried all the combination of showAsAction="" and setIconified() and setIconifiedByDefault() but not getting the desired result.
I want to use the default search view not custom if it is possible. I have searched a lot for this.
Is there any way(or link) by which i can get the desired output.
menu.xml:
android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="always">
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
SearchManager manager = (SearchManager)getSystemService(Context.SEARCH_SERVICE);
searchView =(SearchView)enuItemCompat.getActionView(menu.findItem(R.id.action_search));
searchView.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(mOnQueryTextListener);
searchView.setIconified(false);
Thanks in advance...

Related

Switch to another window in Cypress

I want to switch to to a new window on pressing a button, and the new window has dynamic URL, How do we handle this. Is there any workaround. I searched through many articles
Click the add button
cy.get('a[href*="javascript:xxxSearch();"]').click()
It opens a new window
I want to access(search/add the elements in new window and then switch back to previous main window
May be a good idea if you could share the full html of that page. As I understood from the question, may be grab the href and then get the attribute of href to a const and visit to that link as below. Just give a try and let me know if this is working for you.
it('Open a new window',function(){
cy.visit('some_url')
//test code continues....
cy.get('a[href="/some/link"]').then(($href)=>{
const hrefLink = $href.attr('href');
cy.visit(hrefLink);
// rest of you test to grab the search button
})
})

Navigation Architecture Component - search using SearchView

i researched many posts and articles around this, but could not get a good answer.
i am running into issues while implementing search using Navigation Architecture component.
i have a MainActivity, mainFragment and a searchFragment. mainFragment is set as destination in my navigationGraph. i have these doubts
1. Search should be made part of activity or mainFragment what is the right approach.
2. If search is made part of Activity then handling the up button for my search becomes an issue. the up button on search exits the MainActivity, does not land in mainFragment. I was thinking that NavController should have stack containing mainFragment and then searchFragment, once you press up button in searchFragment, it should popout and mainFragment should display. Looks like i am missing something.

How to Scroll In an Android Tab Using UIAutomator

i am trying to Scroll Using UIAutomator. The Scenario is I am entering the Settings menu in the tab and clicking on Apps options which gives me a list of all the apps in the tab. NOw i want to scroll the list of apps and this is where i am facing issues.It scrolls the Settings options and not the App list. I am attaching a screen shot and my piece of code.
UiScrollable scroll = new UiScrollable(
new UiSelector().scrollable(true));
scroll.setAsVerticalList();
UiObject Apps = scroll.getChildByText(new UiSelector()
.className(android.widget.TextView.class.getName()),
"Apps");
Apps.clickAndWaitForNewWindow();
UiObject Locker = scroll.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),"Content Locker");
Locker.clickAndWaitForNewWindow();
I am new to UiAutomator too and there is not very big amount of tutorials to learn it. I used Smrti example here, but some of the things already got deprecated, so I corrected it a bit to make everything work. Here's what I got
UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.pressHome();
UiObject allAppsButton = mDevice
.findObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.scrollIntoView(new UiSelector().text("Settings"));
mDevice.findObject(new UiSelector().text("Settings")).clickAndWaitForNewWindow();
mDevice.findObject(new UiSelector().text("Apps")).click();
I didn't include the search for certain app here, I'm sure you can manage it the same way as searching for the Settings app in my code snippet.
Say I want to click on App Facebook which is a little down the Apps list under Settings.
You can use this -
getUiDevice().pressHome();
allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.click();
appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
selector = new UiSelector().className(android.widget.TextView.class.getName());
appToLaunch = appViews.getChildByText(selector, "Settings");
if (appToLaunch != null)
appToLaunch.clickAndWaitForNewWindow();
new UiObject(new UiSelector().text("Apps")).click();
UiScrollable appViews1 = new UiScrollable(newUiSelector().scrollable(true));
appViews1.scrollForward();
appViews1.scrollTextIntoView("Facebook");
new UiObject(new UiSelector().text("Facebook")).click();
This should work.

Google Apps Script listbox to dropdown box

I'm building a UI in Google Sites using Apps Script and I am able to create a listbox. According to the documentation if you change the setVisibleItemCount to 1 it will become a dropdown box.
I have tried both 1 and 0.
Neither seems to make it a drop-down box. Using Firefox 13.0.1 to view. Have also tried Safari.
Anyone had any luck with this?
Code looks like this:
var vPanel = container.createVerticalPanel();
//List box
var lb = container.createListBox(true).setId('listbox').setName('listbox');
// add items to ListBox
for(var i=0;i<LIST_OF_PROJECTS.length;i++){
lb.addItem(LIST_OF_PROJECTS[i]);
}
vPanel.add(lb);
lb.setVisibleItemCount(1); //supposed to make it a drop-down but doesn't
lb.setSelectedIndex(0);
This is all inside a Google Site and the page that is being displayed is a Apps Script Page. Perhaps you are NOT using Google Sites? Above code gives me a single line but no drop down arrow.
Could you post your relevant code please ?, It's working for me on firefox (slightly differently), chrome & safari. (see screen cap when I click the selector, SetVisibleItemCount is 1)
thx
EDIT : One important point : to get the list acting as a dropdown list you have to choose 'disable multiple selection', in other words : createListBox(false) or no parameter... but not 'true' as it is in your code !! (now we know why it doesn't work in your case ;-)
With this parameter set to false , it works as expected in standalone webapp, embedded on site and linked to spreadsheet without any difference.
Don't call:
setVisibleItemCount
at all.

How can i reload my layout and apply the changes in silverlight 4

i do a localized application using silverligth 4.
after changing my culture thread i do
LayoutRoot.Children.Clear();
MainPage MyPage = new MainPage();
LayoutRoot.Children.Add(MyPage);
but i get an error "value does not fall within the expected range"
how can i reload the layout to apply the language changing
In my case I am trying to reload one of the views into my Mainpage. I've seen all sorts of wild suggestions on how to do this.
My View is Project_ChangeRequest_Details.xaml which is the current view.
Taking almost exclusively from the initial msg of this thread, I wind up doing..
LayoutRoot.Children.Clear();
Page MyPage = new Project_ChangeRequest_Details();
LayoutRoot.Children.Add(MyPage);
Works like a charm!
I'm using Silverlight 4 BTW.
Application.Current.RootVisual.SetValue(ContentProperty, new MainPage());
Have you tried:-
Application.Current.RootVisual = new MainPage();

Resources