在主屏幕小部件中实现ListView

时间:2022-10-06 21:02:17

How to make widget with something like ListView. I've made it using LinearLayout but I don't know how to discover amount of rows. (I want to know exact amount of rows to make widget able to paging)

如何使用ListView来制作小部件。我已经使用了线性布局,但是我不知道如何发现行数。(我想知道使小部件能够分页的确切行数)

I want it to look like this (photoshop and copypast):

我想让它看起来像这样(photoshop和copypast):

在主屏幕小部件中实现ListView

Notes:

注:

  1. Android 2.3.4 and below.
  2. 安卓2.3.4下面。
  3. widget of size 4x4
  4. 小部件的大小4 x4

UPDATE AND CLARIFICATION:

更新和澄清:

When I said "scrollable" I mean scroll by click on UP and DOWN buttons (you see it on the screenshot) ie paging

当我说“可滚动”的时候,我的意思是通过点击上下按钮来滚动(你可以在截图中看到)ie分页

2 个解决方案

#1


2  

I do not know how to determine real size the widget 4x4 in dp. It seems that it can be determined only by knowing the specific device.

我不知道如何在dp中确定小部件4x4的实际大小。似乎只有知道具体的设备才能确定。

You can scroll by fixed number of rows.

您可以按固定的行数滚动。

#2


1  

The only pre 3.0 example with source I know of is the ScrollableContacts project on Google Code. It features a scrollable list in a home screen widget and works from 2.1. However, the widget requires a home replacement - see the project description. The source can be viewed here.

我所知道的唯一一个具有源代码的pre 3.0示例是关于谷歌代码的ScrollableContacts项目。它在主屏幕小部件中提供了一个可滚动列表,可以从2.1开始工作。但是,小部件需要一个家庭替换—请参阅项目描述。源代码可以在这里查看。

#1


2  

I do not know how to determine real size the widget 4x4 in dp. It seems that it can be determined only by knowing the specific device.

我不知道如何在dp中确定小部件4x4的实际大小。似乎只有知道具体的设备才能确定。

You can scroll by fixed number of rows.

您可以按固定的行数滚动。

#2


1  

The only pre 3.0 example with source I know of is the ScrollableContacts project on Google Code. It features a scrollable list in a home screen widget and works from 2.1. However, the widget requires a home replacement - see the project description. The source can be viewed here.

我所知道的唯一一个具有源代码的pre 3.0示例是关于谷歌代码的ScrollableContacts项目。它在主屏幕小部件中提供了一个可滚动列表,可以从2.1开始工作。但是,小部件需要一个家庭替换—请参阅项目描述。源代码可以在这里查看。