I'm implementing a dialog view, using AutoViews that are available in MVVMCross.AutoView.
Does any one know if it is possible to create dinamic sections. e.g. Something like being able to bind the Elements list of a Section, to a notifiable list in the ViewModel.
What you are looking for is not implemented currently within the Dialog part of AutoViews - just as it's not implemented in the source MonoTouch.Dialog or MonoDroid.Dialog
Adding INotifyCollectionChanged-aware sections to Dialog would definitely be possible, but it would require some skill and time to merge it into the Dialog core code.
If your list (ObservableCollection) is standalone, however - if it doesn't rely on sitting within a larger Dialog - then the list part of AutoViews should work OK for you.
You can see a list AutoView implemented in https://github.com/slodge/MvvmCross/blob/vnext/Sample%20-%20CustomerManagement/CustomerManagement%20-%20AutoViews/CustomerManagement/ViewModels/CustomerListViewModel.cs - this works off of an IObservableCollection and seems to update as you add/remove customers.
Note that AutoViews is still very 'young' - and it'll remain so until we start getting a few more platforms working - there are people working on WP and WinRT Dialog implementations, but these are 'spare time' projects and the people are busy!
Related
TalkBack is able to detect accessibility identifiers in my React Native 0.35.0 android app from non-active scenes I previously navigated through. How do I prevent this so only the current scene is used when identifying accessibility identifiers?
For example I have the first page of my app render a ListView of items. These work as expected with accessibility identifiers where any item can be selected.
The problem is when navigate to the next page, a page that only has one line of text, all the ListView items from the previous scene are still accessible when viewing the new scene!
I am using NavigationExperimental, specifically NavigationCardStack, for navigation. I'm aware NavigationCardStack will render each visited scenes in the stack but am looking to find a way so only the active scene is selectable.
So far I've tried implementing a version of NavigationExperimental that only renders the active scene. While it solves this problem the navigation animations are ruined and navigating back through the app must re-create each scene which creates a sluggish and unacceptable experience in my opinion.
While I don't love the solution I thought setting accessible={false} on every component from the first page may work. Unfortunately even this still left the Text components accessible. If it had worked I could have set accessible to NavigationExperimental's property scene.isActive.
I was able to resolve this issue. In React Native there is an attribute Android can set called importantForAccessibility. It's a little more intensive than I'd prefer but I implemented my own NavigationCardStack and NavigationCard (extended React Native's version to add my own logic in render).
Essentially while iterating over each scene in NavigationCardStack I pass a new property, isActiveScreen which I set to true only on the active scene by inspecting the current index.
Then in NavigationCard I leverage importantForAccessibility by adding
importantForAccessibility={this.props.isActiveScreen ? 'yes' : 'no-hide-descendants'}
In this way on android only my currently visible scene has accessibility enabled while all other scenes in the stack have no-hide-descendants set.
I have had the same issue using the react-navigation library. I was able to modify the react-navigation/src/views/CardStack/Card.jsin order to fix this which can be found here, I just modify the render method (Can't get the code to format :()
Card.js # Github
The following are my modifcations to this:
// Fixes an issue on Android whereby talkback/voiceover will pick up elements on a child view that is not active in the stack navigator
if(this.props.scene.isActive) {
importantForAccessibility='yes';
} else {
importantForAccessibility='no-hide-descendants';
}
return (
<Animated.View
pointerEvents={pointerEvents}
ref={this.props.onComponentRef}
style={[styles.main, style]}
importantForAccessibility={importantForAccessibility}
>
{children}
</Animated.View>
);
This fix has also been forked on github & published to NPM if anyone needs it as follows:
https://github.com/awseeley/react-navigation
https://www.npmjs.com/package/react-navigation-awseeley
We all know segmented control that is IOS but not in android. So I have an application that need something like that. For example let suppose I have a list of students and teacher marks the student either absent or present. and on click of each option there is a service call . for this I am using a library which is as follows:
compile 'info.hoang8f:android-segmented:1.0.6'
As I told you I have a list of students so in list I have the following case;
Case 1: If the teacher review the attendance the of last day , I fetch a list of students that are either absent or present. So on this , the segmented control that I am using in list fires the onCheckChangedlistener which run the code which is also performing some task , where as I only want to perform the task only when user change the listener. In short listener should not fire when I change any check pragmatically. and Also it fires the onCheckChangedListener multiple times. which creates problem for me :
So I have couple of question:
1) what can be used in android in place of the Segmented control library as I stated above.
2) what is possible workaround for this problem. I tried using flag but I am working in getview of listview.
this is a good library in response to what you achieve. I have used this and found the similar problem. So hence by putting flag , and making a raw check over it does a work for me . But As you are using list, i think you can not achieve what you are looking for.
I will suggest to use the radio button to get the check or you can make your custom control like this and see this library
I'm programming an app using android studio. I want to know in which way I can do a tutorial that users will see only the first time that use the app. Tutorial like image or screenshoots
Can someone help me? Thanks
I encountered this thread while looking for a solution for running a tutorial only at the first time (as rbaleksandar suggested), so in case it will be helpful for someone someday, here's a template of a solution that works for me (using the SharedPreferences API):
#Override
protected void onResume() {
super.onResume();
String tutorialKey = "SOME_KEY";
Boolean firstTime = getPreferences(MODE_PRIVATE).getBoolean(tutorialKey, true);
if (firstTime) {
runTutorial(); // here you do what you want to do - an activity tutorial in my case
getPreferences(MODE_PRIVATE).edit().putBoolean(tutorialKey, false).apply();
}
}
EDIT - BONUS - If you're into app tutorial - I'm messing now with the ShowcaseView library (which is amazing - try it out). Apparently they have some shortcut for that issue using a method called singleShot(long) - its input is a key for the SharedPreferences, and it does the exact same thing - runs only in the first activation. Example of usage (taken from here):
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_shot);
Target viewTarget = new ViewTarget(R.id.button, this);
new ShowcaseView.Builder(this)
.setTarget(viewTarget)
.setContentTitle(R.string.title_single_shot)
.setContentText(R.string.R_string_desc_single_shot)
.singleShot(42)
.build();
}
You could always code your own solution, but, let us not reinvent the wheel.
Check this Android Library:
Tour Guide Repository
It allows you to add pointers in your screen, so the user knows where is he supposed to touch next.
It's pretty easy to use, you only need to point to the element you want the user to touch.
From the doc:
Let's say you have a button like this where you want user to click on:
Button button = (Button)findViewById(R.id.button);
You can add the tutorial pointer on top of it by:
TourGuide mTourGuideHandler = TourGuide.init(this).with(TourGuide.Technique.Click)
.setPointer(new Pointer())
.setToolTip(new ToolTip().setTitle("Welcome!").setDescription("Click on Get Started to begin..."))
.setOverlay(new Overlay())
.playOn(button);
Hope this helps!
Some links to libraries for creating introduction and/or tutorial screens.
Horizontal cards like Google Now:
https://github.com/PaoloRotolo/AppIntro
Tutorial screen:
https://github.com/amlcurran/ShowcaseView
As far as I understand the question is not How do I create a tutorial? (as the people who have already posted an answer have concluded) but instead How to show a tutorial upon first launch only?. So here are my two cents on this topic:
I'm not familiar with how your Android app stores its configuration data but I will assume that it's either in a database (SQLite) or a text file (plaintext, YAML, XML - whatever). Add a configuration entry to wherever the app's settings are being stored - something like tutorial_on : false, tutorial_on : 1 etc. depending on the format the configuration is represented in.
The way configurations work is that whenever an app (or software in general) is launched it has to be loaded in the app itself. So add the following to your app (where and how is up to you and your app design):
Check tutorial_on entry
If tutorial_on is set to true/1 whatever
2.1 Display tutorial
2.2 Change tutorial_on to false/0 whatever
2.3 Store the result in your configuration
Continue using the app
By doing so the first time your app launches the flag responsible for displaying the tutorial will be toggled and afterwards every time you start the app the toggle flag will be read leading to omitting the tutorial.
Personally I would suggest that you an option similar to Don't show tutorial anymore along with a description how to re-enable it (by triggering some action in that app's menu etc.). This has two major benefits:
Improved user experience - users like to have control (especially over trivial matters such as showing or hiding a tutorial). Whenever you take the control away from them, they get pissed off.
Enable your user to re-learn forgotten things - a general rule of thumb is to create apps that should not burden the user with a lot of stuff to remember. That is why things should be self-explanatory. However sometimes you may want to do that nonetheless. By adding the possibility that the user re-launches (by simply resetting the tutorial_on flag and repeating the steps from above) the tutorial allows just that - refreshing a user's memory.
First of all I'm not native english speaker so I'm sorry if there is any grammar or spilling mistakes but I'm really trying to do my best here.
OK, I'm developing an application in android system for e-commerce, the user can add any product to sell, but as you know there are many filters questions.
For example if the user want to sell a car he has to select the model and the company of the car, but if he want to sell a mobile then the questions changed to select the storage for example and the model and the company questions will be deleted, so the questions here are dynamic.
I already developed the form using RecyclerView and its look great.
figure1
figure2
figure3
The problem that when I used
notifydatasetchanged
The form data get mixed!
I solved this problem using
notifyItemRangeRemoved and notifyItemRangeInserted
So it's working great, but I still confused why this is happened?
The second problem that is the dynamic form is a fragment called "DynamicFormBuilderFragment" and sometimes I have to replace it with another fragment like "Google Maps fragment" for example the problem that when I call back the "DynamicFormBuilderFragment" all my data is Lost and the form get duplicated!
Like this
figure4
I want to put some codes but really I don't know what to put because they all are too long and complex, but for start I think this problem because I made the RecyclerView.Adapter not static, I will try for now to made it static and see what happens, but I still need your help please.
Thanks for reading and I wish to you a great day and happy coding.
Update
this is my java files and classes
AddAds.class extends ActionBarActivity
DynamicFormBuilderFragment.class extends Fragment // is contain RecyclerView + Adapter + LoadToAdapter + questions classes and it's where dynamic form get build.
GoogleMaps.class extends Fragment
SLOVED!
I Replaced the RecyclerView with the ListView and it's working great now so thanks #greenapps.
I think it's a bug so I will reported to Google.
I have been creating Spinner controls (Combo boxes/Drop downs) in one of my apps, and was surprised to find out how difficult it was to achieve all of the following features:
User facing Strings are externalized, taking advantage of strings.xml internationalisation (I18N) feature of Android.
Spinner selections operate using a System view, which facilitates not having to work with or map Strings to meaningful values (yuck).
User view to System view mapping should be easy, automated and minimal (i.e not hand rolled for every component).
Others have attempted solutions to this, but universally as far as I could see they suffer from one or many of the following problems:
UI code is creeping into their enum class which doesn’t belong there (messy), nearly all existing solutions suffered from this.
Hardcoded User facing Strings in their enum classes. Because these are not externalized you cannot do I18N using the stock Android features.
Authors typically make the Fragment or Activity an OnItemSelectedListener which perpetuates a common problem of inheritance for convenience, where composition is more appropriate.
I have developed my own solution which does this: http://www.androidanalyse.com/android-spinner-externalize-user-strings-mapped-to-system-enum/
My question is, have I missed something? This seems like something that should not have been this hard (which makes me feel like I'm possibly reinventing the wheel).
Below is some example code showing my solution in-use (which is available Apache 2 license from the link above).
String none = getString(R.string.none);
String light = getString(R.string.light);
String medium = getString(R.string.medium);
String strong = getString(R.string.strong);
SpinnerUtil.createNewSpinner(view, R.id.wind, Arrays.asList(none, light, medium, strong), WindLevel.values(),
new SpinnerItemSelectedListener<WindLevel>() {
public void onItemSelected(Spinner item, WindLevel value) {
// Take whatever action you wish to here.
}});
I would just use ArrayAdapter<WindLevel>. Yes, you created a custom typed listener, but the regular event listener gets the position and can call getItem() on the ArrayAdapter<WindLevel> to get a WindLevel properly typed.
IMHO, the vast majority of Spinner widgets will be populated with material read in from a database, the Internet, or some other dynamic data source, rather than populated by some sort of enum with display values coming from static strings that can be internationalized ahead of time.
This is not to say that your code is useless: if you find it useful, then it was worth writing. And I am sure that there are apps out there that contain your targeted pattern (i.e., a Spinner backed by an enum or equivalent where the display values are known in advance and can be internationalized) who might find your solution useful as well. Every developer who writes enough code cooks up these sorts of helper classes and the like that help map an OS or framework model into something that better fits the developer's own mental model. So long as you are not perceiving any performance issues, it's all good.
Also, note that OnItemSelectedListener is an interface; implementing that interface on an existing class is not inheritance.
I believe the reason nobody answered you is :
What problem are you trying to solve ? Spinners existed prior to your well designed attempt.
Why reinvent them in exactly the same way they exist in Android ?
http://developer.android.com/guide/topics/ui/controls/spinner.html
It is a beautiful wheel indeed you designed, but still, it is just a wheel :)
UPDATE :
I think I begin to understand what you did. This is interesting. I'm not sure why you did not go to the pattern implemented by the ListPreference with its entries and entryvalues.
In fact, I'm not sure I understand why the Android team did not go that route either.
In any case, it is worth proposing your idea to the Android framework. It is after all open source.