简体   繁体   English

处理多个“添加”屏幕的最佳方法是什么

[英]What is the best way to handle multiple “add” screens

I am making an android app, using Xamarin, that allows a user to add and then view various types of information. 我正在使用Xamarin制作一个Android应用程序,该应用程序允许用户添加然后查看各种类型的信息。 Currently I made an 'add item' screen for each type of information the user is able to store but that is currently 11 screens and when I add the display views then that is 11 more. 目前,我为用户能够存储的每种类型的信息制作了一个“添加项目”屏幕,但当前为11个屏幕,而当我添加显示视图时,则为11个屏幕。 Eventually that could grow to even more. 最终,这个数字可能还会增加。 Is there a better way to handle this sort of thing? 有没有更好的方法来处理这种事情?

More Detail: 更多详情:

To do a very simple example using 2 items, lets say a user can store the following information about a Car: 为了使用两个项目做一个非常简单的示例,假设用户可以存储有关汽车的以下信息:

  1. Exterior Color 外观颜色
  2. Interior Color 内部颜色
  3. Amount of Doors. 门数量。

Then lets say the user can store the following about a Building: 然后,假设用户可以存储有关建筑物的以下内容:

  1. Amt of Floors 地板高度
  2. Address 地址
  3. Phone Number 电话号码

For the car 'add item' screen I would want textviews and plainviews for each of that information and then lets say I would want a box at the bottom to allow a user to upload an image. 对于汽车的“添加项目”屏幕,我需要每个信息的文本视图和纯视图,然后说我希望在底部的框允许用户上传图像。 Then for the building 'add item' screen i want to have, again, textviews and plainviews for each piece of information but this time I want there to be a box for notes at the bottom instead. 然后,对于建筑物的“添加项目”屏幕,我再次希望每条信息都具有textviews和plainviews,但是这次我希望在底部有一个用于注释的框。

Again this is a simple example. 同样,这是一个简单的例子。 In reality the screens look pretty different overall but serve the same functionality in the sense that they allow a user to add information, but that information is also much different then each other for the most part. 实际上,屏幕在整体上看起来很不一样,但是在某种意义上说它们具有相同的功能,即它们允许用户添加信息,但是这些信息在大多数情况下彼此之间也有很大不同。

TLDR : What is the best way to handle screens that serve the same relative purpose but look differently? TLDR :处理具有相同相对目的但外观不同的屏幕的最佳方法是什么? Do I make separate activities and layouts for each add screen or is there a way to use a master layout/activity that changes based on the type of item being added? 我是否为每个添加屏幕分别进行活动和布局,或者是否可以使用根据要添加的项目类型而变化的主布局/活动?

PS: I do not think using Xamarin plays any part in this but I wanted to mention it to be safe. PS:我认为使用Xamarin不会起到任何作用,但我想提一下它是安全的。

What is the best way to handle screens that serve the same relative purpose but look differently? 处理具有相同相对目的但外观不同的屏幕的最佳方法是什么?

  1. Abstract out the same part of the layouts. 提取出布局的相同部分。 For example Both your "car" and "Building" layout should have "upload image" mode. 例如,“汽车”和“建筑物”布局均应具有“上传图片”模式。 when you design this kind of layout. 当您设计这种布局时。 You can use <include> tag as follows 您可以使用<include>标签,如下所示

     <include layout="@layout/upload_image" android:layout_width="wrap_content" android:layout_height="wrap_content" /> 
  2. Dynamic layout is also suitable for you. 动态布局也适合您。 For example both "car" and "Building" layout need some textView, your can write as following code: 例如,“汽车”和“建筑”布局都需要一些textView,您可以编写以下代码:

     public class DynamicLayout : LinearLayout { private List<LinearLayout> layouts; public DynamicLayout(Context context, int textViewcount) : base(context) { this.Initialize(textViewcount); } protected override void OnSizeChanged(int w, int h, int oldw, int oldh) { base.OnSizeChanged(w, h, oldw, oldh); foreach (var l in layouts) { l.LayoutParameters = new LinearLayout.LayoutParams(w / layouts.Count, ViewGroup.LayoutParams.WrapContent); } } private void Initialize(int textViewcount) { this.Orientation = Orientation.Horizontal; layouts = new List<LinearLayout>(); for (int n = 0; n < textViewcount; n++) { var layout = new LinearLayout(this.Context) { Orientation = Orientation.Vertical, LayoutParameters = new LinearLayout.LayoutParams(this.Width / textViewcount, ViewGroup.LayoutParams.WrapContent) }; layouts.Add(layout); if ("car") { var textView = new TextView(this.Context) { Text = "Car" }; layout.AddView(textView); } else if ("building") { var textView = new TextView(this.Context) { Text = "building" }; layout.AddView(textView); } this.AddView(layout); } } } 

    But Dynamic layout is hard to control the display of the views. 但是动态布局很难控制视图的显示。 If the two methods are used in combination that could be better. 如果将两种方法结合使用,效果会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 支持多个屏幕的最佳方法? -安卓 - Best way to support multiple screens? - Android 具有背景图像的布局,针对不同屏幕处理该图像的最佳实践是什么 - Layout that has background image, what is the best practice to handle that for different screens 在不使用片段的情况下构建首选项屏幕的最佳 Compose 方法是什么? - What is the best Compose way to build preference screens without using a fragment? 在应用程序中添加对多种语言的支持的最佳方式是什么? - What's the best way to add support for multiple languages in an app? 处理DialogFragment回调的最佳方法是什么? - What is the best way to handle DialogFragment callbacks? 从IntentService处理回调的最佳方法是什么 - What is the best way to handle callback from IntentService 在 flutter 中处理大文件的最佳方法是什么? - What is the best way to handle large files in flutter? 在Android中处理Feed的最佳方法是什么? - What is the best way to handle feed in Android? 在 Recycleview 上处理大量数据的最佳方法是什么 - What is the Best way to handle a lot of data on a Recycleview 处理多个片段的最佳方法(嵌套) - Best way to handle multiple fragments (nested)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM