I'm writing an Android app using Titanium Alloy.
This app has multiple View files and it is based on a lot of Windows elements.
Just for making a simple example, think about this:
I have two View files: index.xml (with its Controller index.js) and win02.xml (with its Controller win02.js). index.xml has a Button. I want to open win02 from index by pressing its Button and I want everything about index to be removed from memory so I avoid possible memory leaks.
Inside index.js, I put this code:
btn.addEventListener('click', function(e){
Alloy.createController('win02').getView().open();
});
And, in doing so, I am able to open the win02 Window. But how can I totally remove index? Thanks.
To remove a window you can call close() so $.index.close(); just after you create win02, that should do the trick.
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
I'm trying to create a cross platform app using Xamarin.Forms. As far as I know, the UI will be created from the code and the .axml file will be generated automatically.
Can I modify the .axml file to edit the UI? I tried editing but all that comes up is what is written in the code. ie: hello forms
UPDATE
public static Page GetMainPage ()
{
return new simplerow ();
}
In Xamarin.Forms you can create your pages from markup definitions that are shared across all platforms.
Typically you will write all your content pages using Xamarin.Forms, however you can mix-and-match native pages into an application should you so wish.
These shared common pages, written in Xamarin.Forms, will reside maybe in a PCL project, or a Shared Project so these can then be re-used in the platform-specific projects, each targeting a specific platform OS.
You can write these common pages, either in code, or in XAML. You can even choose to write some pages one way, and some the other if you so choose.
A Xamarin.Forms page is processed at runtime through the interpretation of the page composition that has been created.
Each control that is specified on a page, has its own platform specific renderer, behind the scenes, that will produce output that is targetted to that OS.
When writing Xamarin.Forms pages, for-the-most, you will start to learn a new way of creating pages that is abstracted from the intricacies of creating mobile applications on each different platform OS.
There is therefore no editable .axml that is generated etc as you will write your pages using Xamarin.Forms markup and controls, and even your own or other custom-controls to produce your own application pages.
The following link shows some examples of how to write XAML pages.
The following link shows some examples of how to write from code-behind pages.
Along with the previous answer re: .xaml instead of .axml, you need to remember to change the startup code in app.cs to use your new .xaml form. Replace the "new ContentPage {...};" with "new MyForm();" (where "MyForm" is the name of your shiny new XAML form).
EDIT: Downloaded the project from the dropbox link. Comments below...
I see several issues here. I think you may need to go through the walkthroughs and sample applications provided by Xamarin to get up to speed with the concepts behind XF apps.
First, you are trying to use an Activity as your application's page. In a Xamarin Forms app, it must be a View of some sort, not a platform-specific visual such as Activity.
Second, remove the "test.xml" file from your Android project's Resources/layout folder; while XAML files are indeed XML, they have an 1) have a file extension of .xaml and 2) belong in the shared project.
Here's what you need to do to get your project working: (I'm assuming you're using VS here, under Xamarin Studio, it's slightly different.)
Right-click your "testforms" shared project
Click Add from the context menu and select "New Item"
In the dialog that appears, select "Forms XAML Page" and in the Name area enter a name (such as "MyForm")
(If you're using XS, choose "New File" and "Forms ContentPage")
This will add two files to your project: a XAML file containing your layout (e.g.: MyForm.xaml), and a code-behind file (e.g.: MyForm.xaml.cs).
Open the XAML file, and modify the Label element so that the Text attribute is
Text = "Hello, World!"
Modify the body of GetMainPage in your App.cs to the following:
return new MyForm();
Run the app
Hope this helps!
You got it wrong. Forms are created either through code or XAML. No axml or anything persistent is generated at platform level, everything is done in runtime(XAML is sort of compiled at compile time).
So, modify either code or XAML if you wish to change something. Or, if you need something more demanding, than consider either subclassing an existing Renderer or create you own.
i have an App which is running good, but now i want to open that app on Keyguard
i mean while my phone is lock i can still able to open my app
like Camera App while the phone is call we can still use camera just like that i want to open my app without opening the lockscreen
help me what should i do to make this work
have edited the xml file
home_screen | keyguard
as a widget but its not working
can anyone help me on this !!
Run the str_ireplace code to insert the smilies after you use htmlspecialchars instead of before.
If you add htmlspecialchars() function after replacing the smileys with HTML Tags. It will not work correctly.
Output will be as
<strong>Name :</strong> I am Happy <img src="happy.png">
There are two solution to make it work.
Soln 1 :
Don't convert the text into emoticons before storing it in database. While showing it to the user.
First use htmlspecialchars(), then use strireplace().
Soln 2:
First convert the whole message using htmlspecialchars() , then convert the emoticons using strireplace(). After that, Store the result in the database.
Maybe this question has been ask already, but could not find any answer for almost 2hours of internet search.
There is a graphical UI designer wich is coming along with the last android SDK.
Looks pretty cool and well done.
Nevertheless I * cannot find how to attach an event to the control through the graphical editor.
Of course I can add it manually into the xml, but in that case, what's the purpose of having such tool without that function ?
I mean all the other SDK I had in other languages always include that function.
I've also not been able to find doc about how to use this tool. Quite sad...
Thanks
If you want to add a click event handler, select the button (widget) in the GUI that you want to listen for, and look for the property onClick. Enter the name of the method you want to call when the user clicks on that widget, like.. onMyButtonClick
Then add the method to your Activity
public void onMyButtonClick(View v) {
// I heard the button click
}
The GUI builder is getting there, and is not yet as easy to use as the one in XCode, but it's not hard when you get used to it.
I am currently trying to use the android library android fu to help me with my first proper app.
I am trying to makea test project using the droid fu library but when ever i go to test the app it force closes.
I have used an example of the asynctask and when i test the app it loads and does what its meant to but when i replace it with the betterasynctask the app force closes.
You can download the source of the test app from http://androidapp.dino-digital.com/DroidFuTest.zip
This is caused by you not providing a valid resource pointer for your dialog. Right after you instantiate the task -- try calling the task.disableDialog(); method. It should work after that.
EDIT: Seeing as the user wants a custom dialog -- I'd point you to this link. Just create a new custom dialog(or just use the Android's helper methods for creating a dialog) and reference that ID from your code.
Even though hwrdprkns was correct as to disabling the dialog will make the app work to be able to get the progress dialog to work i add to the following to get the dialog to work.
Call both lines to set the dialog content
super.setProgressDialogTitleId(R.string.dialog_title);
super.setProgressDialogMsgId(R.string.dialog_message);
OR
define "droidfu_progress_dialog_title" and droidfu_progress_dialog_message in your strings.xml