Xamarin,Android How to navigate between two axml pages - android

I have an axml page called Main.axml and a MainActivity.cs file ,i collect values from textbox in axml page and update it in database using web services after updating the database i want to move to a an axml page which just displays the text "Thank you for entering the data".Can anyone please tell how to navigate to another axml page from MainActivity.cs
i tried this in windows mobile app ,but it is not working for Xamarin android :
this.NavigationService.Navigate(new Uri("/Thanks.xaml", UriKind.RelativeOrAbsolute));

Thanks #Artur Shamsutdinov for the link to the article.For anyone who wants to skip reading the article .Please find below the code we have to use in our Activity Page,
var intent = new Intent(this, typeof(ThankyouActivity));
StartActivity(intent);
in ThankYouActivity.cs we can use this code to show the axml page,which will then show thankyou.axml on screen
SetContentView(Resource.Layout.thankyou);

You can also use the following short way:
StartActivity(typeof(ThankyouActivity));

You can use it:
Button thankYou = FindViewById<Button>(Resource.Id.btnThankYou);
thankYou.Click += delegate { StartActivity(typeof(ThankYouActivity)); };

Related

How to open common incomplete products link with different toolbar in android studio

I have an eCommerce website and that has been running as an android app using WebView method. I have basic knowledge in android studio but not depth. My concern is wanna open Second Activity from Main Activity when user clicks on any product in app that contains link as "https://www.ecommerce.in/product/XXXXX". Here "https://www.ecommerce.in/product/" is common to all products but "XXXXX" will change to every product when user clicks on different products and this Second Activity should open using another toolbar without related to Main Activity toolbar and my code is like this:
webView.setWebViewClient(new ourViewClient()
{
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
if(url.contains("https://www.ecommerce.in/product/XXXXX"))
{
Intent intent = new Intent(MainActivity.this, ProductsActivity.class);
startActivity(intent);
}
}
});
This code is not working at all. Hope, I get a solution for this and thank you for your help in advance.
First, it looks like you're trying to filter out links with a contains:
if(url.contains("https://www.ecommerce.in/product/XXXXX"))
But you've made it too restrictive. It is literally looking for "XXXXX" in the URL. Also, this doesn't really get you much in terms of security. WebViews are very dangerous. I'd suggest looking through this link for some basic suggestions.
Anyways, if you just want to open the ProductActivity it looks like all you have to do is update the test as follows:
if (url.startsWith("https://www.ecommerce.in/product/"))
Note if you need that URL then you have to pass it to the ProductActivity as part of the intent and grab it in the ProductActivity, but be sure to verify the URL before just loading it to make sure sit starts with the common part.
It might be that someone is trying to get your Activity to do things it shouldn't be.

Insert icon in a tabbed page(Android) on xamarin form

I'm new to StackOverflow community!
I need help with one problem with android in Xamarin Forms. To be precise... I tried with some friends to build our first app. We choose(with the help of our University professor) Xamarin for the cross-platform development of Android and iOS for both systems using the Xamarin Forms. I created the interface part of the app and now I am stuck in a fort with big walls. When I try to add a Tabbed Page the icon for the functional bar, the app crashes(Android) but in iOS, the problem doesn't appear...
I'd try with some solution... like :
-Render in the NameApp.Droid adds different renderer only for the android part but no result...
-Try another way to insert the icon in the .xaml file directly but no result...
-Try to follow another way to modify the .axam file for the "Theme" part
but no result...
I want to integrate all the stuff on time only in the "Main Project". I don't want for now touch the "nameProject.Droid" or "nameProject.iOS" part, But try to make in one shoot both(Andriod & iOS). I've found a different bug in Android (è.é) but for this, I am going crazy...
But I need to modify the ".Droid" no problem I accept the challenge!
This is the result I aspire to create.
"https://storage.googleapis.com/material-design/publish/material_v_12/assets/0B6Okdz75tqQsbHJuWi04N0ZIc0E/components-tabs-usage-mobile7.png"
This is the way I add the Icon in the Tabbed Page. An assumption I add all the stuff in the "Resource" in ".Droid" and ".iOS :
var MainPageTabbed = new MPageTabbed();
var Profile = new Profile();
var ListChat = new ListChat();
if (Device.RuntimePlatform == Device.Android)
{
MainPageTabbed.Icon = "ldpi.png";
Profile.Icon = "ldpi2.png";
Chat.Icon = "ldpi1.png";
}
if (Device.RuntimePlatform == Device.iOS)
{
MainPageTabbed.Icon = "ldpi.png";
Profile.Icon = "ldpi2.png";
ListChat.Icon = "ldpi1.png";
}
NavigationPage.SetHasNavigationBar(this, false);
Children.Add(MainPageTabbed);
Children.Add(Profile);
Children.Add(ListChat);
Someone can help me please to find a solution?
Here you have an example of how to use the TabbedPage in xamarin forms:
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/tabbed-page/
... Xamarin.forms renders Android tabbed-pages as something called a viewpager combined with a TabPagerStrib, and it looks like the example in the link above.
You might read about BottomNavigationBar for Android instead, or look at this link for a TabPagerStrip with an image:
https://forums.xamarin.com/discussion/39937/adding-icons-to-a-pagertabstrip-instead-of-text
If anyone is interested in a FontAwesome custom icon implementation I followed this tutorial to begin with: FontAwesome with Xamarin Forms
Unfortunately he doesn't give an example of integrating with tabbed pages but after some experimenting I finally figured out a simplified Xaml way to render it without a custom tabbed renderer:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:IBMobile.Views"
xmlns:local2="clr-namespace:FontAwesome"
x:Class="IBMobile.Views.HomePage"
Visual="Material">
<ContentPage.IconImageSource>
<FontImageSource FontFamily="{StaticResource FontAwesomeSolid}" Glyph="{x:Static local2:IconFont.Home}" />
</ContentPage.IconImageSource>

Open a website inside app using corona

I want the user to open website / web page inside app and not in browser. I have a button, which should open a webpage on click.
I am using native.showWebPopup function for this in main.lua. The problem that I am getting is, a white colored page flashes and disappears immediately.
Below is my code. Any help is greatly appreciated. Thanks.
function openLink(event)
if(event.phase == "ended")then
native.showWebPopup("http://www.google.co.in")
end
end
btn:addEventListener("touch", openLink)
Make sure you check that you've provided access to the internet on Android!
Referring to the documentation: http://docs.coronalabs.com/api/library/native/showWebPopup.html
For Android
If the web popup is displaying web pages from the Internet, you must add the INTERNET permission to the build.settings file.
settings =
{
android =
{
usesPermissions =
{
"android.permission.INTERNET",
},
},
}
Other than that, the syntax looks correct, so I suspect it is a permissions problem.
Hope that helps!

How to refresh Radio button on multipage jquerymobile

Is there any example on refreshing the radio-buttons value, that exist on one page and their value is changed from other page.
I have tried the following but its not working. [ using phonegap+jquerymobile+HTML5 ]
The following is the jquerymobile syntax called by the main page while the radio buttons exist on page2:-
if (result.rows.item(0).pri==0)
{
$('#radio2').prop('checked', true);
}
else {
$('input:radio[id=radio3]').prop('checked', true);
}
$("input[type='radio']").checkboxradio();
$("input[type='radio']").checkboxradio("refresh");
getting the following error on eclipse Android development studio
cannot call refresh before page initialization.
any suggestions??
you may need to regenerate the widgets (the form element) by .triger("create")
Detail please refer Enhancing new markup from http://demos.jquerymobile.com/1.2.0/docs/pages/page-scripting.html

Progressdialog for phonegap projects

I am very new to html5, css and javascript. i have knowledge in android development.
Now i have started working on phonegap projects.
In my project i want show a loader just like a progressdialog in android when application moves from one screen to another screen or loading something.
Can any one help me to do this in html5?
I had similar need . I was able to do it using navigator object. Please find below sample code
to load data in background
function someJSFunctionLoadingData() {
navigator.notification.activityStart("Your message....", "loading");
////// some activity
navigator.notification.activityStop();
}
Further to navigate around you could use introduce a small delay ( 2 secs) and let progress bar load during that time and then direct user to the url you need. Below is the example for same
function loadMyUrl(){
navigator.notification.activityStart("Loading some url....", "loading");
setTimeout(function loadMyUrl(){
navigator.app.loadUrl('file:///android_asse/www/someurl.html');
navigator.notification.activityStop();
}, 2000 );
}
I got above idea from this link
An easy solution would be to just create a css based spinner element and set it to hidden/visible when needed via your js.
I searched and found tons of examples online here is one for example.

Categories

Resources