Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

Unable to navigate to next 8th page after 7 pages navigated in xamarin forms using prism

$
0
0

I am unable to navigate to 8th from 7th page in prism

Please help....


Implementing Print on a bluetooth printer in Xamarin Forms App

$
0
0

Any one can you please share with us how to working on bluetooth printer and how to print with help of bluetooth printer in xamarin forms xamarin forms? I wasted for days to find a way to work with bluetooth printer.

Thanks,
sudheer G

Facing issue with UITableView SetContentOffset when removing or hiding few cells

$
0
0

I am implementing UITableView with multiple sections. Setting contentoffset programmatically when offset is out of the scope of contentsize, is making top cell or the last cell stuck at the center of the table view. I have applied logic that whenever the user does some action like clicking on a button or gesture, few cells will hide. While hiding the cell I am making the height of those hiding cells 0 as well.

Forms Design

$
0
0

How to achieve the below design by using xaml code.

Errors when referenace android project to ui test project Xamarin

$
0
0

Hello i have a intruder problem, i have created a xamarin form solution with monoandroid 8.1 and .net standard 2.0 and every thing going fine, once i have add UI test project and add android project as reference i see 4 errors but when i build it build successfully and still see error, and when i build it in app center it fails and show me those 4 errors

and this is log from app center

2018-06-11T10:26:21.6746020Z NU1201: Project UserLogin.Android is not compatible with net471 (.NETFramework,Version=v4.7.1). Project UserLogin.Android supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.6783670Z NU1202: Package Xamarin.Android.Support.Design 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Xamarin.Android.Support.Design 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.6823120Z NU1202: Package Xamarin.Android.Support.v7.AppCompat 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Xamarin.Android.Support.v7.AppCompat 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.6861720Z NU1202: Package Xamarin.Android.Support.v4 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Xamarin.Android.Support.v4 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.6902870Z NU1202: Package Xamarin.Android.Support.v7.CardView 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Xamarin.Android.Support.v7.CardView 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.6943750Z NU1202: Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.6981290Z NU1201: Project UserLogin.Android is not compatible with net471 (.NETFramework,Version=v4.7.1) / win. Project UserLogin.Android supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7019080Z NU1202: Package Xamarin.Android.Support.Design 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win. Package Xamarin.Android.Support.Design 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7057150Z NU1202: Package Xamarin.Android.Support.v7.AppCompat 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win. Package Xamarin.Android.Support.v7.AppCompat 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7095020Z NU1202: Package Xamarin.Android.Support.v4 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win. Package Xamarin.Android.Support.v4 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7132900Z NU1202: Package Xamarin.Android.Support.v7.CardView 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win. Package Xamarin.Android.Support.v7.CardView 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7171470Z NU1202: Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win. Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7221190Z NU1201: Project UserLogin.Android is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x64. Project UserLogin.Android supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7278400Z NU1202: Package Xamarin.Android.Support.Design 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x64. Package Xamarin.Android.Support.Design 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7336420Z NU1202: Package Xamarin.Android.Support.v7.AppCompat 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x64. Package Xamarin.Android.Support.v7.AppCompat 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7393870Z NU1202: Package Xamarin.Android.Support.v4 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x64. Package Xamarin.Android.Support.v4 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7451220Z NU1202: Package Xamarin.Android.Support.v7.CardView 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x64. Package Xamarin.Android.Support.v7.CardView 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7509030Z NU1202: Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x64. Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7565940Z NU1201: Project UserLogin.Android is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x86. Project UserLogin.Android supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7622890Z NU1202: Package Xamarin.Android.Support.Design 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x86. Package Xamarin.Android.Support.Design 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7687110Z NU1202: Package Xamarin.Android.Support.v7.AppCompat 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x86. Package Xamarin.Android.Support.v7.AppCompat 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7746930Z NU1202: Package Xamarin.Android.Support.v4 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x86. Package Xamarin.Android.Support.v4 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7802140Z NU1202: Package Xamarin.Android.Support.v7.CardView 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x86. Package Xamarin.Android.Support.v7.CardView 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1) 2018-06-11T10:26:21.7856710Z NU1202: Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 is not compatible with net471 (.NETFramework,Version=v4.7.1) / win-x86. Package Xamarin.Android.Support.v7.MediaRouter 27.0.2 supports: monoandroid81 (MonoAndroid,Version=v8.1)

I am stuck while publishing my ios app

$
0
0

i am stuck on publishing my app on App store.
it has been 5 times & every time people there delay for reply (between 24 and 48 hours). More over, every time re-ask for something else

I am confused with the last review..

What this means:

Guideline 2.2 - Performance - Beta Testing

Your app appears to be a pre-release, test, or trial version with a limited feature set. Apps that are created for demonstration or trial purposes are not appropriate for the App Store.

Next Steps

To resolve this issue, please complete, remove, or fully configure any partially implemented features. Additionally, remove all references to "demo," "trial," "beta," or "test" in your app description, app icon, screenshots, previews, release notes, and binary.

Resources

If you would like to conduct a beta trial for your app, you may wish to review the TestFlight Beta Testing Guide.

Please see attached screenshots for details.

my app on android has been uploaded and there was no problem at all. Why IOS app store is sooooooo confusing
Can any one know what this means..
my app is not pre-release or test or test version...
What are they talking about

The "LinkAssemblies" task failed unexpectedly.

$
0
0

Hello,

I am hoping someone can help me here. I spent the whole morning to resolve this error and hitting the wall each time.

The min. Target framework is Android 5 level 21
Target Android version is Android 9 level 28
Version number 1.1
Version Name 1.1.0

The application works in debug mode but not in the release mode. You can see part of the error below:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(5,5): Error MSB4018: The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Android.Support.V7.App.NotificationCompat/MediaStyle' (defined in assembly 'Plugin.MediaManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Support.V7.App.NotificationCompat/MediaStyle
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType (Mono.Cecil.TypeReference reference) [0x00013] in :0
..........

I appreciate your help and advice.

Kind regards,

Kamal

Performance issues and usability improvements

$
0
0

Hi,

I need some suggestions, help to solve any problems. I have to create a view with a dynamic count of ContentPages. I created two ViewModels, one with a logic and a stop watch and a second one to control the dynamic pages. It looks like this:

CircleViewModel:

public class CircleViewModel: ViewModelBase {
    public ObservableCollection<Circle> Circles { get; set; }

    private string _timeText;

    public string TimeText { 
        get => _timeText; 
        set {
        _timeText = value; 
        OnPropertyChanged();
        }

    // Some ICommands and methods

    public async Task StartStopWatch() { ... }
}

MultiPageViewModel:

public class MultiPageViewModel : ViewModelBase {
public ObservableCollection<CircleViewModel> Pages { get; set; }

private CircleViewModel _currentPage;

public CircleViewModel CurrentPage { 
    get => _currentPage; 
    set {
         _currentPage = value;
        OnPropertyChanged();
    }

 // Some ICommands and methods
}

MultiPageView.xaml:

<ContentPage ...
   BindingContext="{Binding MultiPageViewModel, Source={StaticResource Locator}}">
    <Grid>
        <ListView ItemsSource="{Binding CurrentPage.Circles}"/>
        <Label Text="{Binding CurrentPage.Title}"/>
        <Button Text="{Binding CurrentPage.TimeText}" Command="{Binding CurrentPage.StartWatchCommand}"/>

        <userControls:VerticalTabView ItemsSource="{Binding MultiPageViewModel.Pages, Source={StaticResoruce Locator}}"
        MoreButtonCommand="{Binding MultiPageViewModel.MoreButtonCommand, Source={StaticResource Locator}}"/>
    </Grid>
</ContentPage>

VerticalTabView is a user control to change the current page. I do not like the usability, so I changed the ContentPage to CarouselPage. With UWP it works fine, with Android the scrolling starts to stutter, in the output of Visual Studio appears "The application may be doing too much work on its main thread." and crashes with an OutOfMemory Exception. The CarouselPage does not work with iOS currently.

How can I improve this? I am grateful for any advice. Thank you.


Xamarin DropDown

$
0
0

I want to use a dropdown like that

for both Android and IOS. How can I?

Help with Firebase for Xamarin Forms

$
0
0

Hi,

I am trying to get the Firebase Analytics works for my Xamarin Forms.

Here what I did:

**In Droid Project:
—————————————————

MainActivity.cs:
**

using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Com.OneSignal;
using Syncfusion.SfBusyIndicator.XForms.Droid;
using Syncfusion.ListView.XForms.Android;
using Syncfusion.SfPullToRefresh.XForms.Android;
using Syncfusion.SfNavigationDrawer.XForms.Droid;
using Firebase.Iid;
using Firebase.Analytics;
using Firebase.Crash;

namespace Eithar.Droid
{
    [Activity(Label = "Eithar", Icon = "@drawable/icon", Theme = "@style/MyTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
    {
        FirebaseAnalytics firebaseAnalytics;

        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            // Obtain the FirebaseAnalytics instance.
            firebaseAnalytics = FirebaseAnalytics.GetInstance(this);

            LoadApplication(new App());
        }
    }
}

**FirebaseService.cs
**

using System;
using Android.Content;
using Xamarin.Forms;
using Firebase.Analytics;
using Firebase.Crash;
using Android.OS;

[assembly: Dependency(typeof(Eithar.Droid.FirebaseService))]
namespace Eithar.Droid
{
    public class FirebaseService : IFirebaseService
    {
        FirebaseAnalytics firebaseAnalytics;

        public void Track_App_Page(String PageNameToTrack)
        {
            firebaseAnalytics.SetCurrentScreen(new Android.App.Activity(), "HomePage", "main_screen");
        }
    }
}

**In PCL Project:
———————————————

IFirebaseService.cs
**

using System;

namespace Eithar
{
    public interface IFirebaseService
    {
        void Track_App_Page(String PageNameToTrack);
    }
}

FirebaseDependencyService.cs

using System;
using Xamarin.Forms;

namespace Eithar
{
    public static class FirebaseDependencyService
    {
        public static void Track_App_Page(String PageNameToTrack)
        {
            DependencyService.Get<IFirebaseService>().Track_App_Page(PageNameToTrack);
        }
    }
}

Home.xaml.cs:

protected override void OnAppearing()
{
    base.OnAppearing();

    FirebaseDependencyService.Track_App_Page("HomePage");
}

google-services.json is already added to the project and the Build action is set to GoogleServicesJson

but my app crashes on appearing and it works back when I comment:

// FirebaseDependencyService.Track_App_Page("HomePage");


Where is the problem here please?

Thanks,
Jassim

Xamarin.IOS Always process during background. And UWP Screen transition when tapping notification.

$
0
0

IOS
I want to process during the background.
I would like to do this until the user manually terminates the application.
I do not want background fetch.
I do not want to enable GPS.
I do TCP/IP communication with the PC in the background.
I will notify you after TCP/IP communication.

Is there a good way to do it?

UWP
Screen transition when tapping notification.

How do you do?

WCF PROTECT FROM MITM

$
0
0

I am using PortableClassLibrary for my Xamarin.Forms Project.

A WCF Service using BasicHttpBinding with TransportSecurity is hosted to IIS using HTTPS

When i install fiddler to examine the requests from android device to service and back i can see the response data in xml along with all values returned.

My Question is how can i protect this data?

I try many ways like set the security mode to message but doesn't seem to be supported by xamarin.

Performance issue when trying to dynamically change parts of the content of a page

$
0
0

**I have a pretty simple xamarin app. **

It's split into two sub-views/sub-pages, which splits the page 3/7 in height. This is done by a grid which holds two rowdefinitions and a contentview (BottomViewSubViewHolder) which is placed into Grid.Row=1 (bottom part).

Then I have a button for navigating the subviews, (which switches the bottom subview on tap).

What I do is that I simply switch the content of the BottomViewSubViewHolder. I set it with new different contentviews depending on how many taps.

It seems however that the intital tap, always takes longer, when the content is set, the app freeze for a couple of hundred milliseconds. After that first initial tap however, the following taps will not show any lag in the app.

This is all I do:
var view = new SubView1();
var viewModel = new SubViewModel1(new NavigationService());
view.BindingContext = viewModel;
bottomViewSubViewHolder.Content = view;

  • This worries me a bit. Have you guys experienced anything like this and do you know what to do about it?

  • Is there a better way of trying to change parts of a page dynamically? Should I Make bigger xaml-views and use IsVisible on parts of the view instead?

Xamarin Barcode ZXingBarcodeImageView .. how to set full width available ?

$
0
0

I'm using ZXingBarcodeImageView.... following is my code - the bar code is not using full width available. I'm not sure why ... any help is appreciated...

 <ContentPage.Content>
    <StackLayout Orientation="Vertical" >
        <zxing:ZXingBarcodeImageView x:Name="BarCodeId" 
            BarcodeFormat="CODE_128"
            HorizontalOptions="FillAndExpand"  VerticalOptions="StartAndExpand"                                 BarcodeValue="12345"
            HeightRequest="150" MinimumHeightRequest="150" InputTransparent="True" >
            <zxing:ZXingBarcodeImageView.BarcodeOptions>
                <zxcm:EncodingOptions  Height="150" PureBarcode="True" />
            </zxing:ZXingBarcodeImageView.BarcodeOptions>
        </zxing:ZXingBarcodeImageView>
    </StackLayout>
</ContentPage.Content>

Xamarin Forms. Integrate Firestore with Add/Update examples?

$
0
0

So, im trying to implement this libraries inside my project:
Firestore Android:
https://www.nuget.org/packages/Xamarin.Firebase.Firestore/60.1142.0-beta2

Firestore IOS:
https://www.nuget.org/packages/Xamarin.Firebase.iOS.CloudFirestore/

And I've only found 1 example of how to use them both:
https://github.com/yamachu/Sample-Firebase-Cloud-Firestore-Xamarin.Forms

Since I'm having problems when adding/updating in the mapping of .NET objects to Java/NSObject respectively. Does anyone know a library that provides an example of that?
Thanks!


Example to integrate firestore in Xamarin.Forms Andriod/IOS?

$
0
0

So, im trying to implement this libraries inside my project:
Firestore Android:
https://www.nuget.org/packages/Xamarin.Firebase.Firestore/60.1142.0-beta2

Firestore IOS:
https://www.nuget.org/packages/Xamarin.Firebase.iOS.CloudFirestore/

And I've only found 1 example of how to use them both:
https://github.com/yamachu/Sample-Firebase-Cloud-Firestore-Xamarin.Forms

Since I'm having problems when adding/updating in the mapping of .NET objects to Java/NSObject respectively. Does anyone know a library that provides an example of that?
Thanks!

Creating Apps for SmartTVs with Xamarin?

$
0
0

Hi Folks,
a customer asked me to create an app for SmartTVs and which TVs I recommend him to buy.
Can you recommend me SmartTV that can run Apps created with Xamarin, e.g. running Android? How to install the app on the TV (Sideload vs. AppStore)? Do they support the official Google Play store or do the TV manufacturer have their own AppStores?

Thanks,
Stephan

Xamarin page back pressesd

$
0
0

I call new page from Main Page with this.PushAsync(new Page1());
and in Page 1 call Page2 with this.PushAsync(new Page1());
When clicking back key or from the back button at Page1.I want to go back to Main Page, not Page1. How can I?

App does not start - ViewModel problem?

$
0
0

Hey there. I found some example Code for ViewModel which does not work for me. My problem is that when I start the app it is about to launch and then just closes itself. I get no errors from Visual Studio besides the notification that there is something wrong with XamarinFormsPrevieweriOS.

This is my Code:

SimpleMultiplierViewModel.cs:

namespace BookCodedotNet2
{
    class SimpleMultiplierViewModel : INotifyPropertyChanged
    {
        double multiplicand, multiplier, product;

        public event PropertyChangedEventHandler PropertyChanged;

        public double Multiplicand
        {
            set
            {
                if (multiplicand != value)
                {
                    multiplicand = value;
                    OnPropertyChanged("Multiplicand");
                    UpdateProduct();
                }
            }

            get
            {
                return Multiplicand;
            }
        }

        public double Multiplier
        {
            set
            {
                if (multiplier != value)
                {
                    multiplier = value;
                    OnPropertyChanged("Multiplier");
                    UpdateProduct();
                }
            }

            get
            {
                return multiplier;
            }
        }

        public double Product
        {
            protected set
            {
                if (product != value)
                {
                    product = value;
                    OnPropertyChanged("Product");
                }
            }

            get
            {
                return product;
            }
        }

        void UpdateProduct()
        {
            Product = Multiplicand * Multiplier;
        }

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if(handler != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        public SimpleMultiplierViewModel()
        {
        }
    }
} 

SimpleMultiplierPage.xaml:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="BookCodedotNet2.SimpleMultiplierPage"
             xmlns:local="clr-namespace:BookCodedotNet2"
             Padding="10,0">

    <ContentPage.Resources>
        <ResourceDictionary>
            <local:SimpleMultiplierViewModel x:Key="viewModel"/>

            <Style TargetType="Label">
                <Setter Property="FontSize" Value="Large"/>
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>

    <StackLayout BindingContext="{StaticResource viewModel}">
        <StackLayout VerticalOptions="CenterAndExpand">
            <Slider Value="{Binding Multiplicand}"/>
            <Slider Value="{Binding Multiplier}"/>
        </StackLayout>

        <StackLayout Orientation="Horizontal"
                     Spacing="0"
                     VerticalOptions="CenterAndExpand"
                     HorizontalOptions="Center">
            <Label Text="{Binding Multiplicand, StringFormat='{0:F3}'}"/>
            <Label Text="{Binding Multiplier, StringFormat=' x {0:F3}'}"/>
            <Label Text="{Binding Product, StringFormat=' = {0:F3}'}"/>
        </StackLayout>
    </StackLayout>

</ContentPage>

Changing a specific value in a list during runtime.

$
0
0

Hello everyone,

I have a simple Xamarin.Android-App.

On the Activity of this app, there is a list displayed. Please see following MyActivity.axml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android        ="http://schemas.android.com/apk/res/android"
android:orientation  ="vertical"
android:layout_width ="match_parent"
android:layout_height="match_parent">
<Button
    android:layout_width ="match_parent"
    android:layout_height="wrap_content"
    android:text         ="Click Me"
    android:layout_marginTop   ="20dp"
    android:layout_marginLeft   ="25dp"
    android:layout_marginRight   ="25dp"
    android:id="@+id/button" />
<Space
    android:layout_width="match_parent"
    android:layout_height="25dp"
    android:id="@+id/space" />
<ListView
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/list" />
</LinearLayout>

One row of this list contains simply two entries, please see ListRow.axml:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"     
android:orientation="horizontal"     
android:layout_width="fill_parent"     
android:layout_height="fill_parent">        
    <TextView             
        android:id="@+id/name"            
        android:layout_width="wrap_content"          
        android:layout_height="wrap_content" 
        android:layout_marginLeft  ="5dp"
        android:layout_marginTop   ="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight ="5dp" />
    <TextView             
        android:id="@+id/value"            
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginLeft  ="5dp"
        android:layout_marginTop   ="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginRight ="5dp" />
</RelativeLayout>

So the code-behind of that activity looks like the following:

public class MyActivity : Activity
{
    List<Entry> List = null;

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        SetContentView(Resource.Layout.MyActivity);

        List = PopulateList();
        var lv = FindViewById<ListView>(Resource.Id.list);
        var adapter = new ListAdapter(this, Resource.Layout.List, List);
        lv.Adapter = adapter;

        FindViewById<Button>(Resource.Id.button).Click += OnButtonClick;
    }
}

For the sake of completeness, here is the code for my ListAdapter.cs-class:

class ListAdapter : ArrayAdapter
{
    List<Entry> List;
    public ListAdapter(Context Context, int ListId, List<Entry> List) : base(Context, ListId, List)
    {
        this.List = List;
    }
    public override int Count
    {
        get { return List.Count; }
    }
    public override View GetView(int position, View convertView, ViewGroup parent)
    {
        View v = convertView;
        if (v == null)
        {
            LayoutInflater inflater = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
            v = inflater.Inflate(Resource.Layout.List, parent, false);
        }
        v.FindViewById<TextView>(Resource.Id.name).Text = List[position].Name;
        v.FindViewById<TextView>(Resource.Id.value).Text = "Original Value";
        return v;
    }
}

So my question now is the following: Assuming that there is more than one item within that List. On click of the button, I want to change one specific text within that list. Let's say of the second entry in the list the (Resource.Id.value).Text (which now says "Original Value") to "Changed Value" or something like that. But only of the second one. All the other items should stay the same.

Please see following scenario, maybe it's easier to understand what I am trying to do:

NameValue
Item Number 1Original Value
Item Number 2Original Value
Item Number 3Original Value

[Button Click]

NameValue
Item Number 1Original Value
Item Number 2Changed Value
Item Number 3Original Value

Can anyone maybe help me / tell me how to do this? What does my private void OnButtonClick(object sender, EventArgs e)-method have to look like? How can I access a single entry in that list?

Thanks in advance for all answers and best regards

Viewing all 204402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>