2016-09-12 12 views
0

私はXamarin.Formsレイアウトを使用していますが、それはStepperです。Xamarin Androidでステッパーのネイティブコントロールを使用する方法

のAndroid上で

、それは次のようになります。

enter image description here

今では私がUWP性能はウェイウェイウェイ、通常のスクロール速度を下回っているとして、各プラットフォーム上でカスタムセルを作成する必要があることと思われます。

このページによると、Stepperはアンドロイドでカスタムビューを経由してレンダリングされます。

enter image description here

私はAndroidのレイアウトを作成し、私はStepperRendererを使用するが、私は方法がわかりません viewcell私のカスタム内部のカスタムビューを膨らま:

<LinearLayout 
     android:id="@+id/Layout1" 
     android:orientation="horizontal" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingLeft="10dip"> 
    <TextView 
     android:id="@+id/Text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#FF7F3300" 
     android:textSize="20dip" 
     android:textStyle="italic" /> 
     <!-- NumberPicker is not applicable--> 
    <NumberPicker 
     android:id="@+id/Stepper" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
     <!--StepperRenderer 
     android:id="@+id/Stepper" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /--> 
    <Spinner 
     android:id="@+id/Picker" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 
    </LinearLayout> 


protected override Android.Views.View GetCellCore(Xamarin.Forms.Cell item, Android.Views.View convertView, ViewGroup parent, Context context) 
{ 
    var x = (MyViewCell)item; 

    var view = convertView; 

    if (view == null) 
    { 
    // no view to re-use, create new 
    view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.MyViewCellLayout, null); 
    } 

    view.FindViewById<TextView>(Resource.Id.Text).Text = x.Text; 
    view.FindViewById<NumberPicker>(Resource.Id.Stepper).Value = x.Value; 

    return view; 
} 

私は私のviewCellでそのビューを使用することができますどのように任意のアイデア?

答えて

0

これに関連した同様のスレッドがあります:

https://forums.xamarin.com/discussion/26173/custom-renderer-for-stepper

は、この情報がお役に立てば幸いです。

+0

カスタムXamarin.Formsコントロールを作成する場合に便利ですが、ネイティブパフォーマンスの機能を利用してAndroidプロジェクトにAndroidコントロールが必要です。私はそれを再実装したくない、私はちょうどステッパーレンダラーを再利用したい。 – Nestor

関連する問題