难道是advantagous在我的应用程序扩展android.widget.Adapter? [英] Would it be advantagous to extend android.widget.Adapter in my application?

查看:387
本文介绍了难道是advantagous在我的应用程序扩展android.widget.Adapter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我当前的应用程序,这是在汽车的使用,我展示了一系列的意见在的RelativeLayout(仪表盘)内的任意位置(这将重新present计)。有明显描述那些计,它们的属性,即它们显示测量数据的定位背衬的数据量,等等。

在这一点上,似乎懂事,我创建一个单独的适配器类包含code。该后盾数据转换成相应的规意见。这将遵循现有的Andr​​oid图案做的事情,从而各种类型的视图(ListView中,微调等)接受BaseAdapter的适当子类取接口到背衬数据的照顾。

我正在考虑做的是延长的RelativeLayout,使其接受一个适配器,并调用标准的适配器方法(如 getCount将() getView( ),等等)。我的自定义适配器将应用适当的LayoutParams每个视图,使其适当地定位在RelativeLayout的。

所以,而不是一个具体问题,正因为如此,我只是好奇,想知道使用适配器接口是否适用于这种情况。什么错误我略,在Android库,适配器似乎常用的$列表格式p $ psent信息视图。你认为子类适配器(或BaseAdapter)听起来像我在做什么的良好格局,抑或是通过在数据不是在一个列表psented $ P $的情况下用它去对粮食几分?


解决方案

  

我只是好奇,想知道使用适配器接口是否适合在这种情况下


恕我直言,不,除非你有仪表任意数量。 适配器视图是围绕使用循环模式只需要几个孩子的实际支持0-N的孩子。 适配器的设计是围绕与适配器视图被使用。

In my current application, which is for in-car use, I am displaying a series of Views (which represent gauges) at arbitrary locations within a RelativeLayout (the dashboard). There is obviously an amount of backing data that describes the positioning of those gauges, their attributes, the measurement data that they display, and so forth.

At this point, it would seem sensible for me to create a separate adapter class to contain the code that translates the backing data into the appropriate gauge Views. This would follow the existing Android pattern doing things, whereby various types of View (ListView, Spinner, etc.) accept an appropriate subclass of BaseAdapter to take care of interfacing to the backing data.

What I was considering doing is extending RelativeLayout so that it accepts an Adapter and calls the standard Adapter methods (like getCount(), getView(), and so forth). My custom Adapter would apply appropriate LayoutParams to each View so that it is appropriately positioned in the RelativeLayout.

So, rather than being a specific question as such, I'm just curious to know whether using the Adapter interface is suitable in this instance. What bugs me slightly is that in the Android library, Adapters seem to be commonly used for Views that present information in a list format. Do you think that subclassing Adapter (or BaseAdapter) sounds like a good pattern for what I'm doing, or is it going against the grain somewhat by using it in a situation where data isn't being presented in a list?

解决方案

I'm just curious to know whether using the Adapter interface is suitable in this instance

IMHO, no, unless you have an arbitrary number of gauges. AdapterView is designed around supporting 0-N children using a recycling pattern to only require a few actual children. Adapter is designed around being used with AdapterView.

这篇关于难道是advantagous在我的应用程序扩展android.widget.Adapter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆