After the start of my application the coolbar is loaded and the first item is selected automatically. I don't want that. Is it possible to remove this selection?
Screenshot: http://i.imgur.com/q15X1.png
Thanks in advance.
I think this is because that button (or rather the toolbar) currently has the focus. To remove the focus you have to set it to another control. Did you implement the setFocus() method of your "Übersicht" view?
Related
I'm working on Espresso tests for Android and for one of my actions I want to search a list using a SearchView, select an item and then navigate back to the previous screen (by closing the searchview and then pressing the up button).
I've tried some things to access the up/collapse button of the SearchView to close it (that don't work):
onView(withContentDescription(R.string.abc_action_bar_up_description))
onView(withId(R.id.search_close_btn))
onView(withId(R.id.home))
onView(withId(R.id.homeAsUp))
onView(withId(R.id.collapseActionView))
Espresso.pressBack() (to just navigate back)
I'm hoping someone might know some way to access and close this button, because I have no idea.
Thanks in advance.
Apparantly I had to press the back button twice to navigate out of it, so if anyone would like to know, you need to use Espresso.pressBack(); twice to get out of the search menu.
The correct id is R.id.search_close_btn
onView(withId(R.id.search_close_btn)).perform(click())
I was with the same problem of accessing this up/collapse button and by reading the hierarchy of components I found out that this button has the content description of 'Collapse'. So using the following solved the problem for me:
onView(withContentDescription(androidx.appcompat.R.string.abc_toolbar_collapse_description)).perform(click())
I want to develop an Android app, where start page of the app GUI, will contain 4 vertical layouts in the main layout. Now, in each layout, I want to add buttons/slider dynamically from the app (instead of adding buttons/slider dynamically in the source code). That means, initially all these 4 layouts will be blank and when user will select any button or slider in another layout, to add it in any of this 4 layouts, the button or slider will be added in that layout. User will be able to add max 10 views in any vertical layout and the views can be either button, slider or custom view.
My attempt:
First I tried to create 4 vertical layout under the main layout for startup page and I got succeed.
I also find after searching that its possible to add views dynamically in layouts in android.
dynamically adding a view to activity layout
But most examples, add views dynamically in android by running loops, instantiating the desired view class and then add it in the main layout. Although, in this way, views are added dynamically in the layout, it is done by modifying the source code.
Is it possible to write the source code in a way, so that it can be done directly from the app? So that when user will click on Add a slider in "layout 1", a slider will be added in layout 1 and then again, when the user will click on "Add a button" in layout 1, a button will be added at the end of the slider. User will be able to customize button or slider properties. Also, if the user change the value of the slider, the app will remember its value.
Now, next time, when the app will be opened, those views will be there in the layouts, they will not be deleted and the values will remain unchanged (for example, a ticked check box will remain ticked), so I think I also need some kind of storage or properties manager.
My question is, is it possible to do this in android (because I never seen such apps in android) and if possible, any idea, how can I implement it?
I am totally new to android, so my knowledge is limited but I completed the basic tutorials on android app development and I have plugin development experience in eclipse.
Thanks a lot in. I will highly appreciate your help.
Of course it is possible:
Every layout (like LinearLayout, RelativeLayout etc.) extends the ViewGroup-class, which offers the addView-method.
To add a new view (like a Slider) to one of your layouts, just instantiate it programmatically (via new) in your activity and assign the appropriate LayoutParams to it
To store the state of user added content, it is the easiest to use SharedPreferences - a simple key-value-store which holds data over the application's lifecycle
Yes. This is possible. To create the Views dynamically, you simply have to either extend the class of the View or just say new Button(Context, AttributeSet); (Not only for Button's every View has a constructor that takes an attribute set and a context).
Using Layout.addView() you can add any View to the Layout.
Using SharedPreferences you can indicate what View belongs in what Layout.
If you decide to extend the View's class, make sure not to do too much in it. I tried that once and it just gave me an OOM (OutOfMemory Error) because I had a ton a Views trying to do stuff at the same time.
In Eclipse E4, detached view option is not available but this is very important requirement for our project, So i want to add popup menu in MPart to provide the functionality.
Please guide me how can i add popup menu in MPart. I tried adding it in application model but it seems i am doing something wrong.
Thanks in Advance!
Add a popup menu and handled menu item to the MPart in your .e4xmi
Make sure you get the id's correct. The handler will be the code you want to run
see here for an example:
http://www.vogella.com/tutorials/EclipseRCP/article.html#menuadvanced_popup
I set a picture as background in my main activity with some objects like home.gif, car.gif, dog.gif, etc. All object files are transparent.
I want to highlight this objects that user can interact with it.
I could not found examples in web how to get this effect. So I am asking here.
I would be grateful if you could help me.
Thank you for your time and consideration!
Ciao, Szymon
You want to show the border of the transparent images in an activity?
Then in selector of that view you just add a pressed state which has borders set.
I'd like to get access to the Tabbed Properties View in order to change the displayed tab programatically. When the selection is changed, the default behaviour is to show the same tab for the new selection (if they share a tab descriptor) or else to show the last known tab for that selection. I need to be able to set the tab based on program conditions.
Thanks in advance.
You need to ask for IPropertySheetPage.class adapter from Properties View workbench part, then cast it to org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage in order to call setSelectedTab() on it.
Cheers,
Max